Borrar filtros
Borrar filtros

why my graph is not showing any thing ?

1 visualización (últimos 30 días)
suketu vaidya
suketu vaidya el 21 de Nov. de 2020
Comentada: suketu vaidya el 21 de Nov. de 2020
function Lab02
h = 0.001;
p=1;
x=0:p:0.5;
t = 0:h:0.5;
y = [0];
for i = 1:length(p)-1
k1=f(x(i),y(i));
k2=f(x(i)+1/2*h,y(i)+1/2*k1*h);
k3=f(x(i)+h,y(i)-k1*h+2*k2*h);
y(i+1)=y(i)+h/6*(1*k1+4*k2+1*k3);
end
plot(x,y);
hold on
end
%analitycal solution
function dy=f(x,y)
syms y(x);
ode=(diff(y(x),x,2))+10*y(x) +sin(100*pi*x)==0;
ySol(x) = dsolve(ode);
c1=1;
c2=1;
dy=c2*sin(3.1623*x)+c1*cos(3.1623*x)+(sin(100*pi*x))/((10000*pi*pi)-10);
end

Respuestas (1)

KSSV
KSSV el 21 de Nov. de 2020
Editada: KSSV el 21 de Nov. de 2020
Check this line:
p = 1 ;
x=0:p:0.5;
The above shpuld be repalced with proper value p. Now it will create only one value i.e. x = 0. You should repalce this line with the appropriate stpe size p.
  3 comentarios
KSSV
KSSV el 21 de Nov. de 2020
Did you consider this line:
for i = 1:length(p)-1
Still your code is a mess. What exactly you are trying?
suketu vaidya
suketu vaidya el 21 de Nov. de 2020
i want to solve ranga kutta 3rd order eqvation

Iniciar sesión para comentar.

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by