Timespan within Ode45
Mostrar comentarios más antiguos
Hi there,
I'm writing code to try solve some differential equations.
function Output = example_3(m0,mEnd) % m0 = range of 1000 to 1500 and mEnd = range of 100 to 500 as an example
g0 = 9.81;
Isp = 390;
mdot = 5;
c = Isp.*g0;
mf = m0 - mEnd;
T = mdot .* Isp * g0;
tbo = mf./mdot;
T_Range =[0,tbo];
Y_01 = [0;0];
[tSol_1,YSol_1] = ode45(@deri_Y,T_Range,Y_01);
v_1 = YSol_1(:,1);
h_1 = YSol_1(:,2);
Output = [max(v_1), max(h_1)];
function dYdt = deri_Y(t,Y)
v = Y(1);
h = Y(2);
dvdt = c.*mdot./(m0 - mdot.*t) - g0;
dhdt = v;
dYdt = zeros(size(Y));
dYdt(1) = dvdt;
dYdt(2) = dhdt;
end
end
the function works for single inputs of m0 and mEnd but I would like the function to run for a range of m0 and mEnd values and because of this the value of tbo changes each time and I get an error saying:
"Unable to perform assignment because the left and right sides have a different number of elements.
Error in example_3/deri_Y (line 53)
dYdt(1) = dvdt;
Any help is greatly appreciated.
2 comentarios
darova
el 18 de Feb. de 2021
Did you try for loop to get several solutions?
Dylan Lawley
el 18 de Feb. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming 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!