Error in ODE45

4 次查看(过去 30 天)
Guys I tried to code a Stirred Tank Heater System using MATLAB, I modelled the equation and all
clc;
clear all;
T1_0 = 325.4;
tspan = [0 10];
[tsol,T1sol] = ode45(@(t,T1) heat(t,T1), tspan, T1_0);
plot(tsol,T1sol)
grid on
xlabel('t')
ylabel('T1')
title('Solutions of Heat Balance on Tank-1')
And this is the ode function "heat" that I have used
function dT1 = heat(t,T1)
% Inputs
A2 = 7.854e-05; %Cross-Sectional Area Tank 2
Tc = 303; %Cooling Water Temp
T2 = 320.1; %Tank 2 Temp
h2 = 0.41; %Level h2
rho_w = 1000; %Density in kg/m3
Cp = 4182; %Cp value in J/KgK
u1 = 0.45; %Flow F1
F1_A = 8.0368e-11;
F1_B = 456.85e-11;
F1_C = 42379e-11;
F1 = F1_A*(u1^3)-F1_B*(u1^2)+F1_C*(u1);
u4 = 0.45; %Heat Input Q1
Q1_A = 7.9798;
Q1_B = 0.9893;
Q1_C = 0.0073;
Q1 = Q1_A*(u4)+Q1_B*(u4^2)-Q1_C*(u4^3);
dT1 = (F1(Tc-T1)+Fr(T2-T1)+(Q1/rho_w*Cp))/(A2*h2);
end
But I am getting the following errors when I run the code.
Array indices must be positive integers or logical values.
Error in heat (line 29)
dT1 = (F1(Tc-T1)+Fr(T2-T1)+(Q1/rho_w*Cp))/(A2*h2);
Error in CACE>@(t,T1)heat(t,T1) (line 7)
[tsol,T1sol] = ode45(@(t,T1) heat(t,T1), tspan, T1_0);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in CACE (line 7)
[tsol,T1sol] = ode45(@(t,T1) heat(t,T1), tspan, T1_0);
Please, any help would be nice

采纳的回答

madhan ravi
madhan ravi 2020-10-7
编辑:madhan ravi 2020-10-7
MATLAB doesn't have implicit multiplication, hence:
dT1 = (F1*(Tc-T1)+Fr*(T2-T1)+(Q1/rho_w*Cp))/(A2*h2);
Note: Fr is not defined in your code.
  1 个评论
Ajmal R S
Ajmal R S 2020-10-7
Yes, I forgot to include that, but the mistake was in the multiplication. Thank you

请先登录,再进行评论。

更多回答(1 个)

GRK
GRK 2020-10-7
There are two errors in this code. first one is that there is no variable name called Fr.
Second one is F1 shoulde be multipliead it means you have to use multiply symbole (*) when you want to multiply some thing.
as per my assumption F1 = Fr i think. Just Replace the below Formula with the original formula and Run the program.
dT1 = (F1*(Tc-T1)+F1*(T2-T1)+(Q1/rho_w*Cp))/(A2*h2);
  2 个评论
Ajmal R S
Ajmal R S 2020-10-7
No, I am sorry. It was my mistake. I forgot to add the Fr function, I added it and got the answer. Thank you for your help
SIDDABOENA Laxmi Venkata Sai
share your matlab code AJMAL RS

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by