ODE45 must return column vector
Mostrar comentarios más antiguos
I just have to solve using ode45 for every value of I and plot the solution but i cant quite figure it out.
I=[80,131,189,270,320,407,450,530,620,686,740,900,1095];
t2=[74,29,21,12,8,5.7,4.4,3.6,2.1,1.8,1.5,1.0,0.7];
a=.000104;
b=.000073;
p=1089;
R=0.000003;
n=0.001;
M=0.05;
u=4*pi*10^(-7);
x1=0.36;
alpha=-(p*M*R^2*u.*I)/(9*pi*n);
beta=-(x1*R^2*u.*I.^(2))/(18*pi.^(2)*n);
ode = @(t2,x,I) (1./(alpha.*x^(-2)+beta.*x^(-3)));
for k = 1:numel(I)
[t2,x(:,k)]=ode45(@(t,x) ode(t,x,I(k)),[0:.1:20],0.1);
end
figure
loglog(t2,x)
grid
xlim([0 1])
xlabel('t_1')
ylabel('x')
nstr = compose('I = %.2f',I);
legend(nstr, 'Location','NW')
Aything helps.
Respuesta aceptada
Más respuestas (1)
Ameer Hamza
el 30 de Nov. de 2020
What are the values of alpha and beta you are using? Following code works without error
I=[80,131,189,270,320,407,450,530,620,686,740,900,1095];
t2=[74,29,21,12,8,5.7,4.4,3.6,2.1,1.8,1.5,1.0,0.7];
alpha = 1;
beta = 2;
ode = @(t2,x,I) (1./(alpha.*x^(-2)+beta.*x^(-3)));
for k = 1:numel(I)
[t2,x(:,k)]=ode45(@(t,x) ode(t,x,I(k)),[0:.1:20],0.1);
end
figure
loglog(t2,x)
grid
xlim([0 1])
xlabel('t_1')
ylabel('x')
nstr = compose('I = %.2f',I);
legend(nstr, 'Location','NW')
1 comentario
Henry Jackson
el 30 de Nov. de 2020
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!