Error using "superiorfloat" with ODE23

3 visualizaciones (últimos 30 días)
Javier Enrique Dominguez De Leon
Javier Enrique Dominguez De Leon el 4 de Feb. de 2024
Editada: Walter Roberson el 4 de Feb. de 2024
Hello,
I've been getting the following error when I try to use ODE23 solver:
  • Error using superiorfloat: Inputs must be floats, namely single or double.
  • Error in HW2_3MWK (line 52): [t_m3,P_m3] =ode23(Y3, [(n-1)*Tc; n*Tc] , P0_WK3);
The code in question is the following:
Y3= @(t,y3) (-y3/(R2*C)+I(t)*(R2+R1)/(R2*C)+R1);
[t_m3,P_m3] = ode23(Y3, [(n-1)*Tc; n*Tc] , P0_WK3);
P0_WK3=P_m3(end);
Where R1, R2, C, Tc, and P0_WK3 are pre-stablished constants. (Full code attached)
This code has worked in the past, which is almost 12 years ago (it is not mine), and wanted to re-purpose it for a project. Any ideas?
Thanks in advance!!!
-JD
%%Catanho et al, 2012. Use of numerical solution and MATLAB ODE solver to
%%present the 3-Module model.
close all;
clear ;
colour = hsv;
%Initial parameters
R1 = 0.05; %Systemic resistance from the aorta (mmHg/cm^3/sec)
R2 = 0.9; %Systemoc resistance from the peripheral vessels (mmHg/cm^3/sec)
C = 1.067; %Compliance of the aorta (cm^3/mmHg)
%Assumptions
Tc = 0.8333; %Duration of the cardiac cycle
Ts = (2/5)*Tc; %Duration of systole
cycle = 5; %Amount of cycles considered by the model
%Modelling of the Blood flow in the aorta
%Numerical solution of the integral below will give the estimated flow into
%the aorta per cardiac cycle.
syms Ti q
I0 = solve(90-int(q*(sin(pi*Ti/Ts)),Ti,0,Ts),q);
I0 = subs(I0, '3.14', pi);
sine = @(t) sin(pi*t/Ts);
I = @(t) I0*sine(t).*(t <= Ts);
%Now that the blood flow in a single cycle has been determined, now we will
%see effect of the 3-Module WM over the specified number of cycles
figure(1)
for n =1 : cycle
t = (n-1)*Tc:0.01:n*Tc;
%Blood flow over n cardiac cycle(s)
I=@(t) I0*sine(t-(n-1)*Tc).*(t <= ((n-1)*Tc+Ts)) ;
subplot(2,1,1)
plot (t, I(t), 'LineWidth' , 2)
hold on
xlim([0 n*Tc])
ylim([ 0 600])
title('Aortic Blood Flow')
ylabel('Blood Flow (mL/s)')
xlabel('time(s)')
P0_WK3 = 80; %Initial pressure for the 3-MWK model
%%Numerical Solution for 3 ElementWM
Y3=@(t,y3) (-y3/(R2*C)+I(t)*(R2+R1)/(R2*C)+R1);
[t_m3,P_m3] =ode23(Y3, [(n-1)*Tc; n*Tc] , P0_WK3);
P0_WK3=P_m3(end);
subplot(2,1,2)
plot(t_m3,P_m3, 'LineWidth' , 2)
hold on
ylim([ 0 150])
xlim([0 n*Tc])
title('Aortic Blood Pressure (Numerical 3 ElementWM)')
ylabel('Pressure (mmHg)')
xlabel('time(s)')
end
Error using superiorfloat
Inputs must be floats, namely single or double.

Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);

Error in ode23 (line 102)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);

Respuesta aceptada

Torsten
Torsten el 4 de Feb. de 2024
Replace the line
I0 = subs(I0, '3.14', pi)
by
I0 = double(I0)

Más respuestas (0)

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by