plot differential equation (ODE)

2 ビュー (過去 30 日間)
reem
reem 2012 年 12 月 2 日
コメント済み: Mukhtar Hussain 2014 年 1 月 27 日
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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by