I am having some problems defining a simple function in Matlab, the error says: not enough input arguments! but the function only needs one argument.
The input is A
, a matrix (100 rows, 4 columns)
and what I expect is another matrix.
I save MyFun.m
as a file in order to call it later with @MyFun
.
function [y]= MyFun(A)
a=[nanmean(A(:,3)),nanmean(A(:,4))];
b=sqrt(a(:,1).^2+a(:,2).^2);
c=((atan2d(a(:,2),a(:,1)))./2)+90;
if c<=90
c=c+90;
else
c=c-90;
end
d=[nanstd(A(:,3)),nanstd(A(:,4))];
y=[a,b,c,d]
clear a b c d
end
A = rand(100,4); y = MyFun(A)
That works well for me. Your code runs just fine. – ThalesMyFun(input)
, by adding an@
you are creating a function handle instead of executing the function. But without more info on how you call the function, we cannot answer your question. – rinkertMyfun
andMyFun
are not the same. The file name is the name of the function you call. – Cris Luengo