Error using "superiorfloat" with ODE23
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Structural Mechanics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!