Too Many Input Arguments - I am new to matlab and not sure how to solve this

1 次查看(过去 30 天)
function [h] = thesis(t)
% Oil/Brine Systems Main Characteristics
%% Oil/Water System at 30C (Paraffin)
mu1 = 3.8; % Viscosity in mPa.s-1
rho_O1 = 797; % Oil Density in kg/m3
rho_B1 = 998; % Brine Density in kg/m3
IFT1 = 21; % Interfacial Tension mN/m
g = 9.81; % m2/s
% Concentration for this system is 80ppm
%% Oil/Water System at 40C (Crude Oil A)
mu2 = 5; % Viscosity in mPa.s-1
rho_O2 = 833; % Oil Density in kg/m3
rho_B2 = 994; % Brine Density in kg/m3
IFT2 = 5; % Interfacial Tension mN/m
% Concentration for this system is 200ppm
%% Oil/Water System at 50C (Crude Oil B)
mu3 = 6; % Viscosity in mPa.s-1
rho_O3 = 834; % Oil Density in kg/m3
rho_B3 = 989; % Brine Density in kg/m3
IFT3 = 3; % Interfacial Tension mN/m
% Concentration for this system is 200ppm
%% Oil/Water System at 60C (Crude Oil C)
mu4 =4.9; % Viscosity in mPa.s-1
rho_O4 = 826; % Oil Density in kg/m3
rho_B4 = 985; % Brine Density in kg/m3
IFT4 = 1; % Interfacial Tension mN/m
%Concentration for this system is 200ppm
nd = 1000; % No. of Droplets
Vol = 900; % Liquid volume of emulsion (ml)
l = 0.5; % Mean Distance between droplets
alpha = 0.08; % Empirical Collision Effiency Parameter
D0 = 300; % Initial Droplet Diameter (microns)
%% Sedimentation interface, hs: dhs/dt
Pr0 = ((nd*pi*D0^3)/6)/Vol; % Initial Volume Fraction of droplet
Prm = ((nd*pi*((D0+l)^3))/6)/Vol; % Maximum Volume Fraction of droplet
delrho1 = rho_B2 - rho_O2; % difference between the dispersed water and continuous oil phase
Vsto = (delrho1*g*(D0^2))/18*mu2; % Settling Velocity of Hard Spheres (stoke's velocity)
fPr = (1-Pr0)^5.3; % Dimensionless
x1 = 60; % (hs - hd) in mm, guessed value
K1 = ((2/3)*alpha*((Vsto^2)/D0))*((fPr^2)/((Prm/fPr)^1/3)-1);
h = x1*(K1*t-(Vsto*fPr));
end
I tried everything to figure this out but dont understand what I can do again. Any assistance is greatly appreciated. thanks

采纳的回答

Sam Chak
Sam Chak 2022-6-29
Try fixing these lines
function dhdt = thesis(t, h)
dhdt = x1*(K1*t-(Vsto*fPr));
  3 个评论
Sam Chak
Sam Chak 2022-6-29
编辑:Sam Chak 2022-6-29
If h is really the height of the column. and this line
dhdt = x1*(K1*t-(Vsto*fPr));
and its depending parameters correctly describe the differential equation (how h will change according to time t), then the following MATLAB code should give a result:
tspan = [0 180];
h0 = 240;
[t, h] = ode45(@thesis, tspan, h0);
plot(t, h)
If the result is incorrect (obvious because h exploded to ), something must be incorrect in your thesis function file. Please check at least x1, K1, Vsto, fPr.
x1 = 60; % (hs - hd) in mm, guessed value
K1 = ((2/3)*alpha*((Vsto^2)/D0))*((fPr^2)/((Prm/fPr)^1/3)-1)
K1 = 1.3125e+119 - 4.2645e+118i
At least, mathematically I understand if , then will explode.
Matthew Charles
Matthew Charles 2022-6-29
I understand what you mean here, especially for the values derived for K1, I will review once more and ensure all the formulas for the function is indeed correct. Thank you so much for your assistance

请先登录,再进行评论。

更多回答(1 个)

Saksham Gupta
Saksham Gupta 2022-6-29
As per my understanding of your query, you are getting error in using function 'ode45'.
From the error logs, I can say that 'ode' function in ode45 is getting more arguments than the parameters defined for it.
Upon inspection of code, I realized that 'ode' is nothing but the function handle of 'thesis' function which you are passing.
Your function 'thesis' is expected to accept y0 (which you are passing as [240] to ode45).
If you change the very first line to:
function [h] = thesis (t, y0)
you can get the output.
To explore more about ode45, you may refer the documentation

类别

Help CenterFile Exchange 中查找有关 Electrophysiology 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by