フィルターのクリア

How to plot a summation vs the x

2 ビュー (過去 30 日間)
yang-En Hsiao
yang-En Hsiao 2018 年 7 月 30 日
回答済み: Aquatris 2018 年 7 月 30 日
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?

採用された回答

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by