indicies on left and right are not compatible

1 visualización (últimos 30 días)
BoostedMan
BoostedMan el 10 de Sept. de 2021
Respondida: Walter Roberson el 10 de Sept. de 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 comentarios
BoostedMan
BoostedMan el 10 de Sept. de 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 el 10 de Sept. de 2021
You are indexing i with i. It is a scalar, so that will never work.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 10 de Sept. de 2021
Bend = Force .* (1:length(Force));
No loop needed.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by