How to get the plot from ODE
1 view (last 30 days)
Show older comments
Kartik Lanjewar
on 15 Jan 2024
Commented: Kartik Lanjewar
on 15 Jan 2024
Hello there, I got stuck with the plots which are drawn in the result. How to solve the ODE's to get the required plots for dimensionless number mentioned in the paper, please let me know if anyone can get it ?
0 Comments
Accepted Answer
Sam Chak
on 15 Jan 2024
There are over 50 equations in the PDF, and the ODEs appear in various places. Most forum users don't have the time to read the entire paper and identify which set of ODEs to solve, especially users who are not experts in the film-boiling chemical vapor infiltration process.
You can find examples in the ode45 documentation and follow them to write the MATLAB code for your application. Afterward, post the code so that we can troubleshoot any errors that may arise.
I used the first example here, the popular Van der Pol oscillator in the Electrical Engineering world. They are just a few lines. But the length of the ODE function (odefun) depends on the size of the system that you want to solve.
%% Use ode45 to solve ODEs on time span [0 20] with initial values [2 0]
[t, y] = ode45(@odefun, [0 20], [2; 0]);
%% Plot the results
plot(t, y(:,1), '-o', t, y(:,2), '-o')
%% Labels
title('Solution of van der Pol Equation (\mu = 1) with ODE45');
xlabel('Time t'), ylabel('Solution y'), legend('y_1', 'y_2')
%% ODEs of Van der Pol oscillator
function dydt = odefun(t,y)
dydt = [y(2);
(1 - y(1)^2)*y(2) - y(1)];
end
3 Comments
Sam Chak
on 15 Jan 2024
@Kartik Lanjewar, I can show you a code snippet, but I'm not an expert in film-boiling infiltration dynamics. So, you need to learn how to define the coefficients or parameters in the dynamics.
%% Use ode45 to solve ODEs
[x, y] = ode45(@odefun, [0 1], [0; 1; 0.5]);
%% Plot the results
plot(x, y), grid on
xlabel('\xi')
%% film-boiling infiltration dynamics
function dydx = odefun(x, y)
% Definitions
theta = y(1);
psi = y(2);
epsil = y(3);
% Parameters (define it yourself)
H = 1;
m = 1;
omega = 1;
Phi = 1;
n = 1;
B = 1;
f = 1;
% ODEs
dydx = [- 1/(1 - epsil);
H*epsil^(-(m + 1)) + omega*(Phi^2)*epsil^(-m)
(1/omega)*epsil^(1/n)*(1 - B*epsil)*f*psi];
end
More Answers (1)
AMIT SURYAVANSHI
on 15 Jan 2024
% Define the ODE function
odeFunc = @(t, y) -2 * y;
% Define the time span
tspan = [0 5];
% Specify the initial condition
y0 = 1;
% Solve the ODE using ode45
[t, y] = ode45(odeFunc, tspan, y0);
% Plot the solution
plot(t, y);
xlabel('Time');
ylabel('Solution');
title('ODE Solution');
% Display the plot
grid on;
1 Comment
AMIT SURYAVANSHI
on 15 Jan 2024
In the example above i have used the ode dy/dt=-2y and the begining condition is y(0)=1 it's a basic code but it may help you out their
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!