I have a function in Octave/MATLAB like this:
A = @(x1, x2) [0 1; -1*x1 -0.9*x2^2; x1 3*x2];
And I want to find the dimension of the function. One option to check the amount of columns is:
nargin(A)
Which gives 2
in this case. But how about the rows? I know there are 3
rows. But when I check the dimensions, I'll get:
size(A)
ans =
1 1
How to find the amount of rows of the function A
?
nargin
doesn't check the amount of columns. It returns the number of input arguments of the function instead.
One straight-forward way would be to input any values and then find the size
. i.e.
>> size(A(0,0))
ans =
3 2
If there are a lot of input arguments and you want to automate the process of entering input arguments then:
>> tmp = num2cell(zeros(nargin(A),1));
>> size(A(tmp{:}))
ans =
3 2