Filter löschen
Filter löschen

How to plot a summation vs the x

1 Ansicht (letzte 30 Tage)
yang-En Hsiao
yang-En Hsiao am 30 Jul. 2018
Beantwortet: Aquatris am 30 Jul. 2018
My code is
x =0:1:1000;
y=-((1/2).^x).*log2((1/2).^x);
H=sum(y);
And i want to plot (x,H),however,there is no curve in the figure when using plot(x,H),So i want to ask which command should i use?or if i can use the plot,where is my mistake?

Akzeptierte Antwort

Aquatris
Aquatris am 30 Jul. 2018
When you do sum(y), it sums each element and gives you a scalar value. I think what you want is;
H = cumsum(y);

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by