Could someone please explain...
이전 댓글 표시
...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.
채택된 답변
추가 답변 (1개)
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
카테고리
도움말 센터 및 File Exchange에서 Code Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!