Hi I want to plot t with respect to Vcf in my code , but only obtaining the max plot value only
Show older comments
Vci = 10; Ra = 0.5; Rb = 0.3; delT = 0.5; t = 0; while t < 7; t = t+delT; x = t; Va = Ra.*x; Vb = Rb.*x; Vcf = Vci+Va-Vb; y = Vcf; plot(x,y,'*'); if y < 0 disp('Negative value hence y =0') elseif y > 0 disp(y); disp(x); disp(Va); disp(Vb); end end
Answers (1)
Roger Stafford
on 16 Jan 2015
0 votes
You need to do a "hold on" to combine all the plotted points. Otherwise after each step of the while loop the previous plot gets erased and you get only one new point plotted.
Better still, you should collect the x and y values in arrays and call on 'plot' only after you have exited the while-loop.
Categories
Find more on Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!