plot differential equation (ODE)

3 次查看(过去 30 天)
reem
reem 2012-12-2
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 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2012-12-2
Your title don't correspond to your question
Mukhtar Hussain
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
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);

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by