Cannot get points on a plot to show
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Caleb Maynard
am 29 Jan. 2020
Bearbeitet: Fangjun Jiang
am 29 Jan. 2020
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
0 Kommentare
Akzeptierte Antwort
Fangjun Jiang
am 29 Jan. 2020
Bearbeitet: Fangjun Jiang
am 29 Jan. 2020
You are plotting one point at a time, use
plot(N,error(N),'+')
or at the end,
plot(1:10,error)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots 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!