Not Enough Input Arguments

I am attempting to run someone else's code (not well written, I appreciate), it begins as:
function save_data_R13_MFS(build_variables_R13)
close all
% load Soln_Kn_0.05_Na_10_bc_rad_1_sing_rad_0.2.mat
load(build_variables_R13.m)
N_alpha=N_phi;
sing_rad = sing_rad;
N_phi=N_phi;
N=N;
dg=dg;
The aim is to generate graphs of pressure and velocity using the Green's function for velocity from the build_variables_R13.m file, which starts as follows:
function [...
S11, S12, S13 ,...
S21, S22, S23 ,...
S31, S32, S33 ,...
m111, m112, m113,...
m121, m122, m123,...
m131, m132, m133,...
m211, m212, m213,...
m221, m222, m223,...
m231, m232, m233,...
m311, m312, m313,...
m321, m322, m323,...
m331, m332, m333,...
M1, M2, M3, p, v, q, theta,RGrad] = build_variables_R13
However, when I try to run the code it says that there is an issue with the line load(build_variables_R13.m) because there are not enough input arguments. Did anyone have any ideas or suggestions as why this would not be working? I could try and include more of the code, but it gets really messy after this point, I think I just need an idea of why this particular message might be appearing.

Answers (1)

That is a function. You do not load() it, you execute it and assign outputs to variables.
[Outs{1:44}] = build_variables_R13() ;
And then extract entries from the cell Outs.
I notice that immediately after the load() that variables are used that are not in the workspace and do not correspond to names that are output, such as N_phi. I worry that that might be an internal variable from the function that is not being returned.
I also notice that the name of the build function appears to be passed in to the save* function. How is that being passed? As a character vector that includes a .m extension? That includes a directory path? Handle to anonymous function?

6 Comments

I have tried this
[Outs{1:44}] = build_variables_R13() ;
but am still getting the message that there are too many input arguments. I am not sure how it is being passed to be honest, it is just some code that I inherited from someone else and I am seeing if I can get it to work. Obviously, it is a mess, I just want to run it and see where everything is coming from.
We need your current code including the call to the save_data* routine.
I can post the entire code but it is very long and hard to read (this is not my code and was sent by somone else.
function save_data_R13_MFS(build_variables_R13)
close all
% load Soln_Kn_0.05_Na_10_bc_rad_1_sing_rad_0.2.mat
N_alpha=N_phi;
sing_rad = sing_rad;
N_phi=N_phi;
N=N;
dg=dg;
%--------------------------------------------------------------%
% Automatically generated boundary conditions from Mathematica %
%--------------------------------------------------------------%
% U_inf = -U_inf;
Debug = 0;
Kn = Kn;
N_spheres = 1;
Centres = zeros(3,N_spheres);
[...
S11, S12, S13 ,...
S21, S22, S23 ,...
S31, S32, S33 ,...
m111, m112, m113,...
m121, m122, m123,...
m131, m132, m133,...
m211, m212, m213,...
m221, m222, m223,...
m231, m232, m233,...
m311, m312, m313,...
m321, m322, m323,...
m331, m332, m333,...
M1, M2, M3, p, v, q, theta,RGrad] = build_variables_R13;
S = @(x,y,z,DOF,Kn)...
[S11(x,y,z,DOF,Kn), S12(x,y,z,DOF,Kn), S13(x,y,z,DOF,Kn);
S21(x,y,z,DOF,Kn), S22(x,y,z,DOF,Kn), S23(x,y,z,DOF,Kn);
S31(x,y,z,DOF,Kn), S32(x,y,z,DOF,Kn), S33(x,y,z,DOF,Kn)];
[Posn_Spherical,...
Posn_Sphere_n,...
Normal_Sphere,...
Polar_Sphere,...
Azimth_Sphere,...
Azimth_Sphere1,...
Vector_Outer_Product,...
EYE,...
J,...
K,...
Eval_J,...
Eval_K,...
get_sphere_no,...
get_local_ii,...
get_alpha_ii,...
get_phi_jj,...
get_alpha,...
get_phi,...
Q_Matrix,...
M_Vec,...
Alpha_Vec,...
Beta...
] = build_fns(N,N_spheres,Kn,Centres,Debug);
[R13VelRadial,R13VelPolar, R13Temp,FR13,R13QRadial,R13QPolar,R13SigRR,R13SigRth,R13Press] = R13_Analytic_Solution;
%------------------------------%
% Compare solution to analytic %
%------------------------------%
Temp_Wall = 1;
U_inf = 0;
v_wall = [0 0 U_inf];
for jj = 1:N
get_sphere_no = floor((jj-1)/(N))+1;
get_local_ii = mod(jj-1,(N))+1;
get_alpha_ii = (get_local_ii >1 && get_local_ii <(N))*(floor((get_local_ii -2)/N_phi)+1);
get_phi_jj = (get_local_ii >1 && get_local_ii <(N))*(mod((get_local_ii -2),N_phi)+1);
if(get_local_ii == 1)
alpha = 0; phi = 0;
elseif(get_local_ii == N_alpha*N_phi+2)
alpha = pi; phi = 0;
else
alpha = (get_alpha_ii *pi)/(N_alpha+1);
phi = ((get_phi_jj -1)*2*pi)/N_phi;
end
bbj = dg*(jj-1)+1; % define jj block
n=[sin(alpha)*cos(phi);sin(alpha)*sin(phi);cos(alpha)]'; % Could be generalised using dr/d\alpha \times dr/d\phi
t=[cos(alpha)*cos(phi);cos(alpha)*sin(phi);-sin(alpha)]';
s=[-sin(alpha)*sin(phi);sin(alpha)*cos(phi);0]'./norm([-sin(alpha)*sin(phi);sin(alpha)*cos(phi);0]);
if(jj==1|| jj==N)
s = [0 1 0];
end
Boundary_Vec(bbj:bbj+dg-1) = [...
(-v_wall)*n',...
(-v_wall)*t',...
(-v_wall)*s',...
Temp_Wall,...
Temp_Wall,...
(-v_wall)*t',...
(-v_wall)*s',...
0,...
0,...
];
end
Soln = Boundary_Vec/RHS;
sprintf('Using pinv')
tol = 1e-10;
Soln = (pinv(RHS')*Boundary_Vec')';
NodeVals = reshape(Soln,[dg,N]);
F_drag_MFS = Soln(4:dg:end);
eta = Kn;
check = sum(F_drag_MFS) - (6*pi*eta*-U_inf)*( ( (1+2*Kn)*(1+(15/4)*Kn) + (Kn^2)*(15/(2*pi)) ) / ( (1+3*Kn)*(1+(15/4)*Kn+(9/pi)*(Kn^2)) - (3/4+9*Kn)*(6/(5*pi)*(Kn^2)) ) );
sprintf('Difference between MFS drag and G13 analytic: %g', check)
sprintf('Difference between MFS drag %g and R13 analytic %g is: %g',sum(F_drag_MFS),FR13(Kn),sum(F_drag_MFS)+FR13(Kn))
inc = 0.05;
x = 1:inc:3;
plot_array = 1:floor(length(x)/20)+4:length(x);
B_p = - ( ( 60*pi + 345*pi*Kn + 450*(1+pi)*Kn^2 ) / ( 40*pi + 270*pi*Kn + 18*(25*pi+18)*Kn^2 + 648*Kn^3 ) ) ;
a = zeros(1,length(x));
b = zeros(1,length(x));
RTemp = zeros(1,length(x));
RVPolar = zeros(1,length(x));
RVRadial = zeros(1,length(x));
Sig = zeros(1,length(x));
c = zeros(1,length(x));
d = zeros(1,length(x));
e = zeros(1,length(x));
f = zeros(1,length(x));
alpha = 0; % Set polar angle of observation point
for index = 1:length(x)
R = (index-1)*inc + 1;
R_Eval = @(r,alpha,phi) r*[sin(alpha)*cos(phi);sin(alpha)*sin(phi);cos(alpha)];
theta_js = zeros(1,N);
vel_js = zeros(3,N);
S_js = zeros(3,3,N);
phi = 0;
for ee = 1:N
% alphaee = ( feval(get_alpha_indx,ee,N_phi)*pi)/(N_alpha+1);
% phiee = (feval(get_phi_indx,ee,N_phi)-1)*2*pi/N_phi;
%
% R_Vec = feval(Posn_Spherical,sing_rad,alphaee,phiee);
R_Vec = get_position_vector(sing_rad,ee,N_alpha,N_phi,N,N_spheres,Kn,Centres,Debug);
Use_R = R_Eval(R,alpha,phi)-R_Vec;
% DOF = zeros(13,1);
DOF = NodeVals(1:dg,ee);
% DOF(9:13)= NodeVals(5:dg,ee)*Kn^2;
theta_js(ee) = theta(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
vel_js(:,ee) = v(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
S_js(:,:,ee) = S(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
end
%Check Temp
B_t = @(alpha) U_inf*(cos(alpha)/(R^2))*( -sqrt(pi/2) * (30*Kn^2 + 180*(1+1/pi)*Kn^3 ) / ( 20*pi + 135*pi*Kn + 9*(25*pi+18)*Kn^2 + 324*Kn^3 ) );
a(index) = sum(theta_js);
b(index) = B_t(alpha);
%Check Vel
Normal_Sphere(alpha,phi);
c(index) = (v_wall'+sum(vel_js,2))'*Normal_Sphere(alpha,phi);
d(index) = (v_wall'+sum(vel_js,2))'*[cos(alpha)*cos(phi); cos(alpha)*sin(phi);-sin(alpha)];
e(index) = U_inf*( 1 + B_p/R - (1+B_p)/(R^3) )*cos(alpha); %Radial
f(index) = -U_inf*( 1 + B_p/(2*R) + (1+B_p)/(2*R^3) )*sin(alpha); %Polar
Sig(index) = dot(Normal_Sphere(alpha,phi),sum(S_js,3)'*Normal_Sphere(alpha,phi));
end
%
% plot(x,a/U_inf,'-b')
% plot(x(plot_array),b(plot_array)/abs(U_inf),'^','MarkerEdgeColor','red','MarkerFaceColor','red','MarkerSize',4)
% plot(x(plot_array),R13Temp(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_Theta_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','a','plot_array','b','Kn')
%plot(x,Sig,'-b')
%plot(x(plot_array),R13SigRR(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_S_rr_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','Sig','plot_array','Kn')
%---------------------------------------------------------------------------------------------------------------------------------------------
alpha = pi; % Set polar angle of observation point
Q_r = zeros(1,length(x));
Q_th = zeros(1,length(x));
for index = 1:length(x)
R = (index-1)*inc + 1;
R_Eval = @(r,alpha,phi) r*[sin(alpha)*cos(phi);sin(alpha)*sin(phi);cos(alpha)];
p_js = zeros(1,N);
vel_js = zeros(3,N);
q_js = zeros(3,N);
phi = 0;
for ee = 1:N
% alphaee = ( feval(get_alpha_indx,ee,N_phi)*pi)/(N_alpha+1);
% phiee = (feval(get_phi_indx,ee,N_phi)-1)*2*pi/N_phi;
%
% R_Vec = feval(Posn_Spherical,sing_rad,alphaee,phiee);
R_Vec = get_position_vector(sing_rad,ee,N_alpha,N_phi,N,N_spheres,Kn,Centres,Debug);
Use_R = R_Eval(R,alpha,phi)-R_Vec;
DOF = NodeVals(1:dg,ee);
p_js(ee) = p(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
vel_js(:,ee) = v(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
q_js(:,ee) = q(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
end
Normal_Sphere(alpha,phi);
a(index) = sum(p_js);
c(index) = (v_wall'+sum(vel_js,2))'*Normal_Sphere(alpha,phi);%+U_inf*cos(alpha);
d(index) = (v_wall'+sum(vel_js,2))'*[cos(alpha)*cos(phi); cos(alpha)*sin(phi);-sin(alpha)];%-U_inf*sin(alpha);
Q_r(index) = sum(q_js,2)'*Normal_Sphere(alpha,phi);
e(index) = U_inf*( 1 + B_p/R - (1+B_p)/(R^3) )*cos(alpha); %Radial
f(index) = -U_inf*( 1 + B_p/(2*R) + (1+B_p)/(2*R^3) )*sin(alpha); %Polar
end
%plotx,c/U_inf,'-b')
%plotx(plot_array),e(plot_array)/abs(U_inf),'^','MarkerEdgeColor','red','MarkerFaceColor','red','MarkerSize',4)
%plotx(plot_array),R13VelRadial(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_V_Radial_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','c','e','plot_array','Kn')
%plotx,Q_r/U_inf,'-b')
%plotx(plot_array),R13QRadial(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_Q_Radial_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','Q_r','plot_array','Kn')
%plotx,a/U_inf,'-b')
%plotx(plot_array),R13Press(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_Press_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','a','plot_array','Kn')
%---------------------------------------------------------------------------------------------------------------------------------------------
alpha = pi/2; % Set polar angle of observation point
for index = 1:length(x)
R = (index-1)*inc + 1;
R_Eval = @(r,alpha,phi) r*[sin(alpha)*cos(phi);sin(alpha)*sin(phi);cos(alpha)];
theta_js = zeros(1,N);
vel_js = zeros(3,N);
phi = 0;
for ee = 1:N
% alphaee = ( feval(get_alpha_indx,ee,N_phi)*pi)/(N_alpha+1);
% phiee = (feval(get_phi_indx,ee,N_phi)-1)*2*pi/N_phi;
% R_Vec = feval(Posn_Spherical,sing_rad,alphaee,phiee);
R_Vec = get_position_vector(sing_rad,ee,N_alpha,N_phi,N,N_spheres,Kn,Centres,Debug);
Use_R = R_Eval(R,alpha,phi)-R_Vec;
DOF = NodeVals(1:dg,ee);
theta_js(ee) = theta(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
vel_js(:,ee) = v(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
q_js(:,ee) = q(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
S_js(:,:,ee) = S(Use_R(1),Use_R(2),Use_R(3),DOF,Kn);
end
Normal_Sphere(alpha,phi);
Q_th(index) = sum(q_js,2)'*[cos(alpha)*cos(phi); cos(alpha)*sin(phi);-sin(alpha)];
c(index) = (v_wall'+sum(vel_js,2))'*Normal_Sphere(alpha,phi);
d(index) = (v_wall'+sum(vel_js,2))'*[cos(alpha)*cos(phi); cos(alpha)*sin(phi);-sin(alpha)];
Sig(index) = dot(Normal_Sphere(alpha,phi),sum(S_js,3)'*[cos(alpha)*cos(phi); cos(alpha)*sin(phi);-sin(alpha)]);
e(index) = U_inf*( 1 + B_p/R - (1+B_p)/(R^3) )*cos(alpha); %Radial
f(index) = -U_inf*( 1 + B_p/(2*R) + (1+B_p)/(2*R^3) )*sin(alpha); %Polar
g(index) = ((1 - 3/(4*R) - 1/(4*R^3)).*v_wall -((3/4)*(1/(R^3) - 1/(R^5))*R.*Normal_Sphere(alpha,phi)'.*(dot(R.*Normal_Sphere(alpha,phi),v_wall)))+((1/(R^3))*cross([0 1 0],R*Normal_Sphere(alpha,phi))))*[cos(alpha)*cos(phi); cos(alpha)*sin(phi);-sin(alpha)];
end
%plotx,d/U_inf,'-b')
%plotx(plot_array),f(plot_array)/abs(U_inf),'^','MarkerEdgeColor','red','MarkerFaceColor','red','MarkerSize',4)
%plotx(plot_array),R13VelPolar(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_V_Polar_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','d','f','g','plot_array','Kn')
%plotx,Q_th/U_inf,'-b')
%plotx(plot_array),R13QPolar(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_Q_Polar_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','Q_th','plot_array','Kn')
%plotx,Sig,'-b')
%plotx(plot_array),R13SigRth(x(plot_array),alpha,Kn)/U_inf,'s','MarkerEdgeColor','black','MarkerFaceColor','black','MarkerSize',4)
filename = ['pdata_HT_S_ra_alpha_' num2str(alpha/pi) '_Kn_' num2str(Kn) '_Na_' num2str(N_phi) '_sing_rad_' num2str(sing_rad) '.mat'];
save([ filename], 'Soln','RHS','v_wall','U_inf','sing_rad','Kn','dg','N_phi','N','Temp_Wall','x','Sig','plot_array','Kn')
end
Walter Roberson
Walter Roberson on 6 Aug 2019
Edited: Walter Roberson on 6 Aug 2019
Please show the call to save_data_R13_MFS()
Also, which line is reporting the error about too many input arguments or not enough input arguments?
Tom
Tom on 6 Aug 2019
Edited: Tom on 6 Aug 2019
I'm not sure what you mean about the call to save_data_R13_MFS()
The file is called save_data_R13_MFS.m and it is basically trying to solve a problem with boundary conditions and then find variables like polar component of the velocity, temperature etc.
The fundamental solution for the velocity is in the file build_variables_R13.m which is being called in the file save_data_R13_MFS.m. I can't include the build_variables file as it is a mess, but it starts
function [...
S11, S12, S13 ,...
S21, S22, S23 ,...
S31, S32, S33 ,...
m111, m112, m113,...
m121, m122, m123,...
m131, m132, m133,...
m211, m212, m213,...
m221, m222, m223,...
m231, m232, m233,...
m311, m312, m313,...
m321, m322, m323,...
m331, m332, m333,...
M1, M2, M3, p, v, q, theta,RGrad] = build_variables_R13
p = @(x,y,z,DOF,Kn) (1/72).*exp(1).^((-1).*(5/6).^(1/2).*Kn.^(-1).*(x.^2+y.^2+z.^2).^(1/2)) ...
.*Kn.^(-1).*pi.^(-1).*(x.^2+y.^2+z.^2).^(-5/2).*(8.*y.^4.*DOF(1)+16.* ...
y.^2.*z.^2.*DOF
It's line 31 which says too many input arguments, where it goes to build_variables_R13.
The file is called save_data_R13_MFS.m
At some point, you invoke save_data_R13_MFS, passing in something . We need to see the place that save_data_R13_MFS is called -- we need to see exactly what is being passed in.

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Asked:

Tom
on 3 Aug 2019

Commented:

on 7 Aug 2019

Community Treasure Hunt

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

Start Hunting!