plot differential equation (ODE)

조회 수: 3 (최근 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 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