MATLAB Answers

ODE 45 range for the variables

조회 수: 7(최근 30일)
N/A
N/A 23 Jun 2020
Hello.
I used ODE45 to solve a system of differential equations dx/dV, dT/dV where V was assigned as t and x,Y as y(1), y(2) respectively. The code works but the numbers are wrong. I want x to be from 0 to 1 and T to be from 298 to 700. How can I implement these inside the ODE function. Is there a way I don't use tspan as a range of the V variable.
Thank you in advance

  댓글 수: 2

Bjorn Gustavsson
Bjorn Gustavsson 23 Jun 2020
How are you going to get ode45 to understand what range of V you want to integrate your ODEs over if not by the mechanism used for that? And why wouldn't that be OK.
As for the range of x and T you have to define the boundary-conditions. Since these seems to be first-order ODEs you can define the initial conditions of both (or initial condition of one and end-condition of the other and solve this as a boundary-value problem). Then ode45 will integrate over your period-of-interest. If that takes your solution out of the range you expect, then that's a problem of how you've implemented the ODE or your expectations.
HTH
N/A
N/A 23 Jun 2020
PLEASE HELP (THANK YOU)
Script 2
function dydt=f(t,y)
dydt = [(362*(10.^6).*(1-y(1))*exp(-8731.7./y(2))) ; (8.98.*(10^13).*(1-y(1))*exp(-8731.7./y(2))+17.685.*(10.^3)*(550-y(2)))];
end
Script 1
clear all;
close all;
%x from 0 to 1
%T from 300 to 700
tspan=[0 tmax];
y0=[0 ; 0]; %initial conditions
[t,y] = ode45(@f,tspan,y0);
figure
plot(t,y(:,1));
ylabel('x');
xlabel('V');
title('V-x');
figure
plot(t,y(:,2));
ylabel('T)');
xlabel('V)');
title('V-T');

Sign in to comment.

답변(1개)

Bjorn Gustavsson
Bjorn Gustavsson 23 Jun 2020
If you want to start your ode-integration at an [x,T]-point of [0,298] you have to define your y0 like this:
y0=[0 ; 298]; %initial conditions
HTH

  댓글 수: 0

Sign in to comment.

태그


Translated by