how to remove a column from a character matrix?

suppose
x= 1001
1001 (x is a character matrix)
i want y=100
100 (last column is removed)

 Accepted Answer

x= '1001 1001' ;
idx = strfind(x,' ') ; % get space position
x(idx-1) = [] ;
x(end) = []

3 Comments

u r code is working if i put all rows in a single row.but for 2 row it is fine if i have number of rows.then how to do
x= ['1001' ;
'1001'] ;
x(:,end) =[]

Sign in to comment.

More Answers (1)

You remove the last column of any matrix, regardless of what type of data it contains, even characters, the same way with:
yourmatrix(:, end) = [];
Unless what you call a character matrix is not a character matrix actually. A character matrix would be:
x = ['1001';'0110']; %for example

1 Comment

Dear guillaume thank you,.. but it is not working it is showing empty matrix

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!