필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by