problem with the code "linalg::delCol"

2 views (last 30 days)
Hanan Emad
Hanan Emad on 8 Dec 2015
Commented: Hanan Emad on 10 Dec 2015
I'm trying to use the code " linalg::delRow" to delete several columns in one time from matrix but it always gives me the error
"Error: Unexpected MATLAB operator."
I do it like that :
A = ([[1, 2, 3, 4], [5, 6, 7, 8]])
linalg::delCol(A, 2)
I don't know what's wrong with that code!!

Answers (1)

Steven Lord
Steven Lord on 8 Dec 2015
As the boxed note at the top of the documentation page states, that command ONLY works in a MuPAD Notebook. You cannot use that in MATLAB. To delete a column of a matrix in MATLAB, assign [] (and it needs to be the literal [], not a variable containing []) to the column as shown in the "Diminishing the Size of a Matrix" section on this documentation page.
  3 Comments
Walter Roberson
Walter Roberson on 9 Dec 2015
A(:,[2 7 8 14]) = [];
would delete columns 2, 7, 8, and 14.
Hanan Emad
Hanan Emad on 10 Dec 2015
thanks soooooo much Walter :))

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!