No values in plot?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Here's the following code I've written to make a plot that is equal to the inverse of mathematical constant e (e). I can't quite figure out why my plot is completely empty when I open it, so I'm thinking I'm missing something somewhere. Any suggestions on what I need to do to get the right plot?
clear;
counter=1;
for i=1:50
My_numb_1=i;
My_numb_2=abs(1./My_numb_1);
My_numb_3=abs(1-My_numb_2);
My_numb_4=abs(My_numb_3.^i);
end
% plot of error vs n
x=counter;
y=My_numb_4;
plot(x,y)
grid on;
title('error vs. n');
xlabel('n');
ylabel('error');
0 Kommentare
Antworten (1)
David Hill
am 24 Sep. 2020
Not sure what you were doing, but each loop iteration you were overriding your data. No loop needed.
My_numb_1=1:50;
My_numb_2=1./My_numb_1;
My_numb_3=1-My_numb_2;
My_numb_4=My_numb_3.^My_numb_1;
plot(My_numb_1,My_numb_4);
grid on;
title('error vs. n');
xlabel('n');
ylabel('error');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Digital Filter Analysis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!