【发布时间】:2015-12-03 08:29:17
【问题描述】:
问题:我有包含 char 单元格的后缀 (137x25) 单元格(Ex postfix(6,8)=postfix{6,8}{1,1})。我想在字符的 (137x25) 单元格中对其进行转换。
后缀是这样创建的:
for l=1:25
[matches(:,l), postfix(:,l)] = regexp(semanticTrajCompact(1,4).TrajCompact,sprintf('%d%d(.*)',digits{1}(l),digits{2}(l)),'match','once','tokens');
end
我尝试了不同的解决方案:
解决方案 1
numIndex = cellfun('isclass', postfix, 'double');
tmpStr = sprintf('%g;', postfix{numIndex});
postfix(numIndex) = dataread('string', tmpStr, '%s', 'delimiter', ';');
解决方案 2
postfix(cellfun(@isempty,postfix))={''};
解决方案 3
postfix(cellfun(@isnumeric, postfix)) = cellfun(@(x) sprintf('%.5f', x), postfix(cellfun(@isnumeric, postfix)), 'UniformOutput', false)
解决方案 4
我尝试使用
char(postix)
此解决方案中的任何一个都将后缀转换为(137x25 字符数组)。你能给我其他的想法吗?
【问题讨论】:
-
您能否举一个小例子(使用类似 2 x 2 单元格数组)说明原始单元格的外观以及您希望得到的结果?