No values in plot?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
David Hill
el 24 de Sept. de 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 comentarios
Ver también
Categorías
Más información sobre Digital Filter Analysis en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!