I have a little bit confusion that how size command work.can body explain please?. For Example
A=[1 2 3;4 5 6;7 8 9];
size(A)
=3 *3
but size(A,1)=3 and size(A,2)=3 and size(A,3)=1 why is size(A,3)=1?
When you are doing ##size(A, 1)## or ##size(A, 2)##, 1 and 2 are dimensions here, not the row or column. Since the array is 3×3 (a two-dimensional matrix), the 1st dimension is 3, and the second is 3.
If you create a 3×3×3 matrix (a three-dimensional matrix), the 3rd dimension would be 3, but any higher order dimensions would be 1.
As a basic rule, if an array ##A## is n-dimensional, then ##size(A, dim)## returns the size of that dimension. If ##dim## exceeds ##n##, then 1 is returned.
Since you've created a two-dimensional array, all command that use dimensions > 2 return 1.
Try this and let me know whether you understand the output (don't copy and paste, as that often generates wrong outputs):