Filter löschen
Filter löschen

how to get cumulative percentage

5 Ansichten (letzte 30 Tage)
liyana nadirah
liyana nadirah am 30 Jan. 2020
Kommentiert: liyana nadirah am 31 Jan. 2020
how to get the cumulative percentage of g using this coding and plot it against t?
l=input('l=')
g = zeros(1, length(0:100));% initialize g with 0's of length t
c = 1;% counter variable
for t=0:100
if t>2 && t<=80
g(c)=((3/(309*1.465))*((((12.6*(t-2))/l)*80.4)-(l/6)));
elseif t>80
g(c)=1-((80.4/309)*exp(((((-3*12.6)/(1.465*l))*(t-80)))));
else
g(c)=0;
end
c = c+1;% increment counter variable
end
format shortG
g
t=0:100;
plot(t,g)

Akzeptierte Antwort

Mohammad Sami
Mohammad Sami am 30 Jan. 2020
gs = cumsum(g);
gs = gs / gs(end) * 100;
plot(t,gs)
  2 Kommentare
liyana nadirah
liyana nadirah am 30 Jan. 2020
tq. it work
liyana nadirah
liyana nadirah am 31 Jan. 2020
but why the plot and the data in output not same?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by