when i am plotting this conditional for loop program no plot is showing only one dot is showing. Can anyone help me about how to display plot? i am using Matlab 2013..

1 view (last 30 days)
% conditional
x= -5:0.005:15;
for k=1:length(x)
if x(k)<0
y(k)=sqrt(x(k)^2+1);
elseif x(k)<=10
y(k)=3*x(k)+1;
elseif x(k)>=10
y(k)=9*sin(5*x(k)-50)+31;
end
end
plot(x(k),y(k),'*--r','linewidth',2,'markeredgecolor','k'),xlabel('x'),ylabel('y')

Answers (1)

Walter Roberson
Walter Roberson on 31 Jul 2016
plot(x,y,'*--r','linewidth',2,'markeredgecolor','k')
You were asking to plot only the very last point, x(k) and y(k)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!