how to convert cell to char ?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Leonardo Wayne
le 1 Avr 2016
Réponse apportée : Image Analyst
le 1 Avr 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 commentaires
Réponse acceptée
KSSV
le 1 Avr 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 commentaires
Plus de réponses (1)
Image Analyst
le 1 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!