Plotting with If-else statement

2 次查看(过去 30 天)
Daryl Chua
Daryl Chua 2019-10-21
Matlab code
im trying to plot but cant properly show it
for i=0:0.1:o4;
if (i<=o1) & (i>=0)
y1=(((Ra/2)*i.^2+(w/6)*i.^3+c1)/(E*I))*1000000;
y2=(((Ra/6)*i.^3+(P1/6)*(i-L1).^3-(w/24)*i.^4+c1*i)/((E*I)/1000.^2));
elseif (i<=o2) & (i>=o3)
y1=(((Ra/2)*i.^2+(P1/2)*(i-L1).^2+(w/6)*i.^3-(w/6)*(i-L1-L2).^3+c1)/(E*I))*1000000;
y2=(((Ra/6)*i.^3+(P1/6)*(i-L1).^3+M/2*(i-(L1+L2)).^2-(w/24)*i.^4+c1*i)/((E*I)/1000.^2));
else (i<=o3)&(i>=o4)
y1=(((Ra/2)*i.^2+(P1/2)*(i-L1).^2+M*(i-(L1+L2))+(P2/2)*(i-L1-L2-L3).^2+(w/6)*i.^3-(w/6)*(i-L1-L2).^3+c1)/(E*I))*1000000;
y2=(((Ra/6)*i.^3+(P1/6)*(i-L1).^3+M/2*(i-(L1+L2)).^2+(P2/6)*(i-L1-L2-L3).^3-(w/24)*i.^4+(w/24)*(i-L1-L2).^4+c1*i)/((E*I)/1000.^2));
end
end
subplot(2,1,2);
plot(i,y1,'b.');
title('Plot of the slope');
subplot(2,1,1);
plot(i,y2,'r.');
title('Plot of the Beam Deflection');

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Mobile Fundamentals 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by