Could someone please explain...

1 次查看(过去 30 天)
Alex
Alex 2012-2-21
编辑: mark 2013-10-19
...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.

采纳的回答

Matt Tearle
Matt Tearle 2012-2-21
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 个评论
Alex
Alex 2012-2-21
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.

请先登录,再进行评论。

更多回答(1 个)

bym
bym 2012-2-21
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

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by