フィルターのクリア

indicies on left and right are not compatible

2 ビュー (過去 30 日間)
BoostedMan
BoostedMan 2021 年 9 月 10 日
回答済み: Walter Roberson 2021 年 9 月 10 日
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 件のコメント
BoostedMan
BoostedMan 2021 年 9 月 10 日
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 2021 年 9 月 10 日
You are indexing i with i. It is a scalar, so that will never work.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 9 月 10 日
Bend = Force .* (1:length(Force));
No loop needed.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by