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

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

Antworten (1)

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.

Kategorien

Mehr zu Graphics Objects finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 16 Jan. 2015

Beantwortet:

am 16 Jan. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by