for ii=1:n \n
if x(ii)<=a
v=((-q*b*x(ii)^2)/(12*E*I))*(3*L+3*a-2*x(ii));
vi=((-q*b*x)/(2*E*I)).*(L+a-x);
else
v=((-q)/(24*E*I))*(x(ii)^4-4*L*x(ii)^3+6*L.^2*x(ii)^2-4*a.^3*x(ii)+a.^4);
vi=((-q)/(6*E*I))*(x(ii)^3-3*L*x(ii)^2+3*L.^2*x(ii)-a.^3);
end
end
subplot(2,1,1); plot(x,v);
title(' ');
subplot(2,1,2); plot(x,vi);
Should there be a 'hold on' somewhere in the code? Thanks

댓글 수: 1

Stephen23
Stephen23 2018년 11월 3일
It is possible that a loop is not required anyway. Please tell us what size the variables are: q, E, I, x, L, etc.

댓글을 달려면 로그인하십시오.

 채택된 답변

madhan ravi
madhan ravi 2018년 11월 3일
편집: madhan ravi 2018년 11월 3일

0 개 추천

for ii=1:n %EDITED
if x(ii)<=a
v(ii)=((-q*b*x(ii)^2)/(12*E*I))*(3*L+3*a-2*x(ii));
vi(ii)=((-q*b*x)/(2*E*I)).*(L+a-x);
else
v(ii)=((-q)/(24*E*I))*(x(ii)^4-4*L*x(ii)^3+6*L.^2*x(ii)^2-4*a.^3*x(ii)+a.^4);
vi(ii)=((-q)/(6*E*I))*(x(ii)^3-3*L*x(ii)^2+3*L.^2*x(ii)-a.^3);
end
end
plot(x(1:numel(v)),v);
hold on
plot(x(1:numel(vi)),vi);

댓글 수: 4

madhan ravi
madhan ravi 2018년 11월 3일
편집: madhan ravi 2018년 11월 3일
The hold on is only required if and obligations you want to put multiple graphs in one plot. (ii) is included next to the variables in order to prevent t overwriting. At the beginning of the loop you put n/n where it should be n otherwise the loop is useless only calculating for the first iteration.
Jacqueline Hoang
Jacqueline Hoang 2018년 11월 3일
Yes, I am trying to graph 2 figures, v(ii) and vi(ii) stacked on top of each other.
madhan ravi
madhan ravi 2018년 11월 3일
편집: madhan ravi 2018년 11월 3일
So use hold on , if it worked make sure to accept the answer so that people know the question is solved.
madhan ravi
madhan ravi 2018년 11월 3일
Else let know what’s additionally required

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

질문:

2018년 11월 3일

댓글:

2018년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by