Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

2 views (last 30 days)
I am trying to choose specific rows from X which is 1149x13120 double. This is the code I am using:
X=([2
4
6],:);
Where 2 4 6 are pasted from an excel spreadsheet. For this particular analysis I only want to analyze data from these 3 subjects. This has worked for me in previous versions of MATLAB, but now I get the error above. Does anyone know what I am doing wrong?
Thanks.
  1 Comment
John D'Errico
John D'Errico on 25 Jan 2016
Edited: John D'Errico on 25 Jan 2016
No. This syntax has NEVER, ever worked in MATLAB. You are mistaken, probably misremembering what you did before. But that is not valid syntax in MATLAB, nor has it ever been so.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 25 Jan 2016
After I edited your Question so I could see the formatting, the problem is that you need to reference a specific array, not simply the subscripts, and put everything on one line. Change the assignment to:
X_246 = X([2 4 6],:);
and if the rest of the array addressing is correct, it should run without error.
NOTE: This is obviously untested code.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!