how to convert cell to char ?

20 visualizzazioni (ultimi 30 giorni)
Leonardo Wayne
Leonardo Wayne il 1 Apr 2016
Risposto: Image Analyst il 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?

Risposta accettata

KSSV
KSSV il 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)) ;

Più risposte (1)

Image Analyst
Image Analyst il 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))

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by