Hi I want to plot t with respect to Vcf in my code , but only obtaining the max plot value only

5 views (last 30 days)
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
Roger Stafford on 16 Jan 2015
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 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!