how to convert cell to char ?
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
KSSV
2016-4-1
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 个评论
更多回答(1 个)
Image Analyst
2016-4-1
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!