I have a column(29,1) and each cell has 4 digits. I want to remove first 2 digits from each cell
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Vishnu Kant
am 15 Aug. 2018
Kommentiert: Vishnu Kant
am 15 Aug. 2018
I have a column(29,1) numeric array and each cell has 4 digits. I want to remove first 2 digits from each cell. for example i have 2123;2156....and i want 23;56....
I have tried converting it into cell array and run following loop: for k = 1 : length(key) cellContents = key{k}; % Truncate and stick back into the cell key{k} = cellContents(3:end); end running this i get column of block/square with no digits thanks
2 Kommentare
Stephen23
am 15 Aug. 2018
@Vishnu Kant: you forgot to tell us one of the most important details: what class is your "column"? Is it a numeric array, or a cell array, or a char array, or a table, or a struct, or ... ?
It might be easiest if you upload the variable in a .mat file by clicking the paperclip button.
Akzeptierte Antwort
Domanic
am 15 Aug. 2018
There are a couple of ways of doing this. If you just want the values, you could use:
A=(5001:5029).'; % the 29x1 vector
result = mod(A,100); % the result
Otherwise, you could obtain the digits as characters using:
A=(5001:5029).'; % the 29x1 vector
B=num2str(A); % convert to a string
result = B(:,end-1:end); % get the last two digits as a character
-D
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!