I am trying to plot N versus error and nothing shows up in the plot.
I am not getting any errors but its not plotting anything.
Any advice is appreciated, code is below.
Thanks
clear,clc;
w = pi/2;
t = 0:0.01:4;
x = t.*(0<t&t<2)+(4-t).*(2<=t&t<=4);
for N = 1:10
Ao = 1;
xhat=Ao;
for q = 1:N
xhat = xhat+(-2./((q.^(2).*pi.^(2)+N))*exp(1i*q*w*t))
xhat = xhat+(-2./((-q).^(2).*pi.^(2)+N)*exp(1i*(-q)*w*t))
end
error(N) = mean((x-xhat).^2);
plot(N,error(N));
hold all
end

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 1월 29일
편집: Fangjun Jiang 2020년 1월 29일

0 개 추천

You are plotting one point at a time, use
plot(N,error(N),'+')
or at the end,
plot(1:10,error)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2020년 1월 29일

편집:

2020년 1월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by