How to plot 3 functions inside if loop??
이전 댓글 표시
function y=h(x,a,b,lf,t)
v=length(x);
for i=1:1:v
Q=((a-(2*a+lf-x(i)))/a)^2;
Z=sqrt(1-Q);
S=((a-x(i))/a)^2;
T=sqrt(1-S);
if ((x(i)>=(lf+a))&&(x(i)<=(lf+2*a)))
plot y(i)=((2*b)+(t)-((2.*b).*Z));
end;
if ((x(i)>=0)&&(x(i)<=a))
plot y(i)=((2*b)+(t)-2*b*T);
end;
if ((x(i)>=a)&&(x(i)<=(lf+a)))
plot y(i)=(t);
end;
end;
답변 (2개)
Image Analyst
2013년 6월 11일
Look up plot() in the help. You're not even close to using it correctly. You need to set up y on a separate line, then do
y = 2*b.....whatever.
plot(t, y, 'b-');
hold on;
I don't believe the loop over i is even needed.
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!