plot differential equation (ODE)
3 次查看(过去 30 天)
显示 更早的评论
please help me to plot this equation y=5*cos(sqrt(2)*x)
This is my plotting but it is not correct
x=0:1:20;
y=zeros(length(x));
for i=1:length(x)
y(i)=5*cos(sqrt(2)*x(i));
end
figure,
plot(y(1:20));
2 个评论
Mukhtar Hussain
2014-1-27
Try this if it works
x=0:0.01:20;
y=zeros(length(x));
for i=1:length(x)
y(i)=5*cos(sqrt(2)*x(i));
end
figure;
plot(x,y);
回答(1 个)
Azzi Abdelmalek
2012-12-2
编辑:Azzi Abdelmalek
2012-12-2
It's not y=zeros(length(x)) but y=zeros(1,length(x));and dont use i ( reserved to complex numbers)
x=0:1:20;
y=zeros(1,length(x));
for ii=1:length(x)
y(ii)=5*cos(sqrt(2)*x(ii));
end
figure,
plot(y);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!