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

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

 Akzeptierte Antwort

Try fixing these lines
function dhdt = thesis(t, h)
dhdt = x1*(K1*t-(Vsto*fPr));

3 Kommentare

Thank you very much! Quick question, I am using the below code in the command window to generate a graph, however the graph I am trying to replicate is not what matlab is giving. See attached
tspan = [0 180];
[t, dhdt] = ode45(@thesis, tspan, [240]);
% where H = 240mm (Height of column)
% plotting graph
plot (t, dhdt(:,1), '-o')
grid on
ylabel ('H(mm)')
xlabel ('Time (s)')
title ('Simulation of Sedimentation-Coalesence Experiment')
When I run this code in the command window for the above function, I am getting this response :
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Graph Generated:
I set the initial value as 240 but even that is not reflected on the graph, Can you assist please?
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.
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by