MATLAB Answers

Could someone please explain...

1 view (last 30 days)
Alex
Alex on 21 Feb 2012
Edited: mark on 19 Oct 2013
...the following error? I've looked in the help files and in previous questions to no avail. I am setting up an iteration as follows:
data = csvread('results_n_solve.csv');
assert (size(data, 2) == 1, ...
'Input data must have exactly one column.');
nsys = size(data, 1);
syms n1
S = n1;
y = 450;
n0 = 1;
n2 = 4.676;
k2 = .091;
d1 = 300;
for k = 1 : nsys
F = r_dat(data((k-1) + (1:1), 1:end));
S(k,:) = solve(F);
end
Where the data is a 1 column by 101 row matrix. The function file r_dat is as follows:
function F = r_dat
theta = (2.*pi().*n1.*d1)./y;
a = n0.*n1 + n0.*n2 - n1.^2 - n1.*n2 + n0.*n1.*cos(theta) - n0.*n2.*cos(theta) + (n1.^2).*cos(theta) - n1.*n2.*cos(theta) + n0.*k2.*sin(theta) + n1.*k2.*sin(theta);
b = n1.*k2 - n0.*k2 + n0.*k2.*cos(theta) + n1.*k2.*cos(theta) - n0.*n1.*sin(theta) + n0.*n2.*sin(theta) - (n1.^2).*sin(theta) + n1.*n2.*sin(theta);
c = n0.*n1 + n0.*n2 + n1.^2 + n1.*n2 + n0.*n1.*cos(theta) - n0.*n2.*cos(theta) - (n1.^2).*cos(theta) + n1.*n2.*cos(theta) + n0.*k2.*sin(theta) - n1.*k2.*sin(theta);
d = n0.*k2.*cos(theta) - n1.*k2.*cos(theta) - n0.*k2 - n1.*k2 - n0.*n1.*sin(theta) + n0.*n2.*sin(theta) + (n1.^2).*sin(theta) - n1.*n2.*sin(theta);
F = @(x) (1./((c.^2+d.^2).^2)).*(((a.*c + b.*d).^2) + ((b.*c - a.*d).^2)) - x(1);
end
Which is sloppy yet functional (hopefully). When I run this, I receive the following error:
Error using ==> r_dat Too many input arguments.
Error in ==> n_solve at 36 F = r_dat(data((k-1) + (1:1), 1:end));
Error in ==> run at 74 evalin('caller',[script ';']);
So, what does it mean by "too many input arguments"? I don't know what its telling me, so I don't know how to begin to fix it. I've tried playing around with all the variables that are involved, but nothing changes.

Accepted Answer

Matt Tearle
Matt Tearle on 21 Feb 2012
r_dat is a function with no input arguments:
function F = r_dat
but you're calling it with an input
F = r_dat(data((k-1) + (1:1), 1:end))
  1 Comment
Alex
Alex on 21 Feb 2012
Thank you, I was able to find the information I need. Of course, solving this has lead to all sorts of new problems, but it's progress.

Sign in to comment.

More Answers (1)

bym
bym on 21 Feb 2012
you have defined your function with no input arguments, therefore passing any arguments to r_dat is an error.
function F = r_dat(x,y) % <-- define r_dat inputs

Community Treasure Hunt

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

Start Hunting!