필터 지우기
필터 지우기

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 CenterFile Exchange에서 2-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