how to convert cell to char ?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leonardo Wayne
am 1 Apr. 2016
Beantwortet: Image Analyst
am 1 Apr. 2016
I have the following cell array called raw. I want to convert the contents of the column 19 into a character array in a and put it in a variable as such :
str = '160225MD0004;#2;#13161504900013;#1';
The str will have only that value. I don't want the first cell 'Part number Details'.
I don't want the extra empty cells [].
Most importantly, I want to automatically detect wherever the '160225MD0004;#2;#13161504900013;#1' is. For now it is in the 6th field. But it could change to 7th field for example.
And the '160225MD0004;#2;#13161504900013;#1' could change into '123345KR00994;#3;#160225MD0004;#2;#13161504900013;#1'; In other words, it could have any length.
How can this be done?
0 Kommentare
Akzeptierte Antwort
KSSV
am 1 Apr. 2016
You can remove all empty cells from a cell array using R(~cellfun('isempty',R)). Eg:
R = cell(10,1) ;
R{2} = rand(3) ;
R{6} = rand(3) ;
l = R(~cellfun('isempty',R)) ;
0 Kommentare
Weitere Antworten (1)
Image Analyst
am 1 Apr. 2016
Try this:
% Create sample data:
ca = {'160225MD0004;#2;#13161504900013;#1;', [], 123, [], '123345KR00994;#3;#160225MD0004;#2;#13161504900013;#1'}
% Get only the part numbers that are strings:
partNumbers = ca(~cellfun(@isnumeric, ca))
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!