plot differential equation (ODE)

3 visualizzazioni (ultimi 30 giorni)
reem
reem il 2 Dic 2012
Commentato: Mukhtar Hussain il 27 Gen 2014
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 Commenti
Azzi Abdelmalek
Azzi Abdelmalek il 2 Dic 2012
Your title don't correspond to your question
Mukhtar Hussain
Mukhtar Hussain il 27 Gen 2014
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);

Accedi per commentare.

Risposte (1)

Azzi Abdelmalek
Azzi Abdelmalek il 2 Dic 2012
Modificato: Azzi Abdelmalek il 2 Dic 2012
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);

Community Treasure Hunt

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

Start Hunting!

Translated by