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