MATLAB Answers

size(m,2) how the function works?

Asked by Shaila parvin on 29 Jun 2013
This question is closed and may reopen in the future if edited.

m=[1,2,3; 4 4 4; 3 3 1];

n=size(m,2);

answer: n=2

I don't understand how this function calculates the answer. Please help me.

  1 Comment

Wayne King
on 29 Jun 2013

So this post was a mistake? You did not get an answer of 2 as you report? Then perhaps we should just delete this post?

Products

No products are associated with this question.

1 Answer

Answer by Wayne King
on 29 Jun 2013
Edited by Wayne King
on 29 Jun 2013
 m=[1,2,3; 4 4 4; 3 3 1];
 n = size(m,2);

returns n = 3

I suspect that you have a different function called size() that precedes the MathWorks' version on your path. Or maybe you have a variable called size() in your program or command window. Both of these possibilities are very bad ideas

If you enter:

>>which size

what do you get. If it says "is a variable", then remove that variable. If you get a path other than something like

matlab\toolbox\matlab\elmat\size

Then remove the other function, or move it to a folder not on the MATLAB path.

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today