Suppose I have a pre-built Matlab function
function A=f(varagin)
...
end
I call f.m in a file main.m.
When calling f.m, the inputs to include depend on the number of columns of two matrices X and Y.
For example, if
d=2;
X=randn(4,d);
Y=randn(4,d);
then
A=f(X(:,1),X(:,2),Y(:,1),Y(:,2));
If
d=3;
X=randn(4,d);
Y=randn(4,d);
then
A=f(X(:,1),X(:,2),X(:,3),Y(:,1),Y(:,2),Y(:,3));
If
d=4;
X=randn(4,d);
Y=randn(4,d);
then
A=f(X(:,1),X(:,2),X(:,3),X(:,4),Y(:,1),Y(:,2),Y(:,3),Y(:,4));
Could you help me to generalise the calling of f.m in main.m with any d?