How can I solve this vector lenght problem?
Show older comments
Hi everyone!
It's been a long time since I used MATLAB for the last time. Unfortunatelly, I got rusty and I'm trying to make some examples to brush up my skills. One of this example drove into a bug that I have no idea what can be and how to solve it. I'm trying to use the ODE45 function (Rugge Kutta Method) but I got this error alert.
@(T,Y)TANKMODEL(T,Y) returns a vector of length 1, but the length of initial conditions vector is 2. The vector returned by @(T,Y)TANKMODEL(T,Y) and the initial conditions vector must have the same number of elements.
Can someone give me a north to solve this?
My code is:
clc;
close all;
format long
%Rugge Kutta Method
tspan = [0 5];
IC = [0 0];
[t,y] = ode45(@(t,y)tankmodel(t,y),tspan ,IC);
%Grafica
figure
plot(t,y)
title('Carbon Concentration');
xlabel('Time (s)');
ylabel('Concentration mg/m^3');
function dydt = tankmodel(t,y,z)
format long
%%%Dataset Parameters
Wgrill = 500; Qink = 100; Cink = 2;QE = 25;CE = 2;Ve= 840;Vk= 280;Ee= 25;Ek= 25;
Qoutk = Qink;
Qoute = Qink + QE;
% Equations
dydt = ((Wgrill + Qink*Cink - Qoutk*y + Ee*z - Ek*y)/Vk);
y(1)= 0;
dzdt = ((QE*CE + Qoutk*y - Qoute*z + Ek*y - Ee*z)/Ve);
z(1) = 0;
end
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!