フィルターのクリア

Could someone please explain...

4 ビュー (過去 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 Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by