Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem with using ODE solvers
Date: Sat, 14 Nov 2009 23:40:20 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 70
Message-ID: <hdnf54$gsb$1@fred.mathworks.com>
References: <hd4gmc$amd$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1258242020 17291 172.30.248.38 (14 Nov 2009 23:40:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 14 Nov 2009 23:40:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1474153
Xref: news.mathworks.com comp.soft-sys.matlab:585157


If I understand this code correctly, then I believe you might have a similar problem since it seems like the ode45 function needs the following arguments. 

ode45(function, time span, initial conditions) 

However, with your ode45 function: 
[t,T]=ode45('odefile_V2',tau,ET,R1,rho1,L1,C1,R3,R2,rho2,L2,C2,rho3,L3,C3);

tau is probably suppose to be the time span, which I think is suppose to be a function. 

But, I am still learning the MATLAB, so a lot of your other code still looks too advanced for me. 

"Markthomas " <cutonem@clarkson.edu> wrote in message <hd4gmc$amd$1@fred.mathworks.com>...
> I am trying to run an ODE case usin ode45... the scripts are seen below:
> ---------------------------------------------code 1------------------------------------------------------------------
> function varargout = odefile_V2(t,T,flag,tau,ET,R1,rho1,L1,C1,R3,R2,rho2,L2,C2,rho3,L3,C3)
> 
> switch flag
>     case ''
>         varargout{1} = f(t,T,tau,ET,R1,rho1,L1,C1,R3,R2,rho2,L2,C2,rho3,L3,C3);
>     case 'init'
>         [varargout{1:3}] = init(tau,ET,R1,rho1,L1,C1,R3,R2,rho2,L2,C2,rho3,L3,C3);
> end
> 
> %--------------------------------------------------------------------------
> function dydt = f(t,T,tau,ET,R1,rho1,L1,C1,R3,R2,rho2,L2,C2,rho3,L3,C3)
> 
> dydt(1) = (-(ET*(T(1)^4-(1200*(1-exp(-t/tau)))^4)+(R1*ET*(T(1)^4-(1200*(1-exp(-t/tau)))^4)+T(1)-T2(t))/R2)/rho1/L1/C1+4*ET*R1*(1200*(1-exp(-t/tau)))^3*((1200/tau)*exp(-t/tau)))/(4*ET*R1*T(1)^3+1);
> dydt(2) = (R3*ET*R1*T(1)^4+R3*T(1)+(-R3-R2)*T(2)-R3*ET*R1*(1200*(1-exp(-t/tau)))^4+R2*T(3))/R2/R3/rho2/L2/C2;
> dydt(3) = (T(2)-T(3))/R3/rho3/L3/C3;
> 
> function [tspan,y0,options] = init(tau,ET,R1,rho1,L1,C1,R3,R2,rho2,L2,C2,rho3,L3,C3)
> tspan = [0; 100];
> y0 = [300; 300; 300];
> options = [];
> ---------------------------------------------code 2------------------------------------------------------------------
> clear; clc; close all
> % Material @ Node 0
> T0_0 = 300;
> % Material @ Node 1
> T1_0 = 300;
> K1 = 60;
> rho1 = 8000;
> C1 = 440;
> L1 = .07;
> % Material @ Node 2
> T2_0 = 300;
> K2 = 1.4;
> rho2 = 1300;
> C2 = 1500;
> L2 = .04;
> % Material @ Node 2
> T3_0 = 300;
> K3 = 50;
> rho3 = 7500;
> C3 = 400;
> L3 = .02;
> %Resistances
> R1 = L1/(2*K1);
> R2 = R1 + (L2/(2*K2));
> R3 = (L2/(2*K2)) + (L3/(2*K3));
> % Other Constants
> ET = 4e-8;
> tau = 50;
> 
> [t,T]=ode45('odefile_V2',tau,ET,R1,rho1,L1,C1,R3,R2,rho2,L2,C2,rho3,L3,C3);
> ------------------------------------------------------------------------------------------------------------------------
> i keep getting errors and was hoping somebody was able to figure out what is going wrong.  I have rewritten the code several times and can't seem to get it to work... any help would be great! 
> 
> Thanks!
> MT