Effacer les filtres
Effacer les filtres

indicies on left and right are not compatible

2 vues (au cours des 30 derniers jours)
BoostedMan
BoostedMan le 10 Sep 2021
So i made a shear force plot, but now im trying to add a plot for the bending moment / max bending moment but I keep getting the message "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side." , I tried changing how Big Bend and BendL are but no luck. heres my code:
clear all
close all
clear varaibles
%Homework 1
%Scenario: Bed is 8ft long with a support at each end, Man is 180lb's
%spread out along the bed
Man = 180; %lb
Bedlength = 8; %ft
Ysum = 0; %sum of forces in Y direction
load = ( Man / Bedlength ) %distributed load
Aforce = ( Man / Bedlength ) * ( 0.5 * Bedlength);
for Blength = [1:8]
Force(Blength) = Aforce - load * Blength %Number for shear diagram
end
Xplot = [1:8]
plot (Xplot, Force) %Shear force plot
title 'Shear Force Diagram'
xlabel 'Bed Length (ft)'
ylabel 'Force (lb)'
hold on
for BendL = [1:8] %since evenly distributed load, max bending moment is up to the midpoint (under the shear line)
Bend(BendL) = Force * BendL
end
plot (1:Bedlength/2,Bend)
  2 commentaires
BoostedMan
BoostedMan le 10 Sep 2021
Update: I changed my for loop and now it says Index exceeds number of array elements (1), code:
for i = [1:4] %since evenly distributed load, max bending moment is up to the midpoint (under the shear line)
Bend(i) = Force(i) * i(i)
end
Rik
Rik le 10 Sep 2021
You are indexing i with i. It is a scalar, so that will never work.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 10 Sep 2021
Bend = Force .* (1:length(Force));
No loop needed.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by