When trying:
a = [ 1 1 ; 1 1 ];
size(a)(1)
I get
Error: ()-indexing must appear last in an index
expression
My understanding is that the result of size(a) is a matrix of size 1 2.
Question: Why does size(a)(1) not work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because you can’t index the result of a function like that in MATLAB without creating a temporary.
will work. There are often other ways of getting what you want, however. In your example, you can make use of the
dimargument in the functionsize(X,dim):That will get you the size of the first dimension directly, avoiding the need to create a temporary variable.