0

我已将数据文件的每一行与n行读入nmatlab中的长度单元格数组。

一个示例行,我的单元格数组的元素看起来像

   ' 21, 0, '1 ',1 , 0.00000, 2, ' Sam ', 1, 1.0000 '

我想形成另一个单元矩阵,上面的行替换为

21, 0, '1 ',1 , 0.00000, 2, ' Sam ', 1, 1.0000

即基本上去除了外部引号。所以这一行的长度应该是 9。

我该怎么做?

4

2 回答 2

0

If 'temp' is a string element of a cell array at the position n and m

temp = var_cell{n,m}

you can remove the elements at both the sides in this way :

temp2 = temp(2:length(temp)-1)
var_cell{n,m} = temp2

if you want to remove also the white spaces:

temp2 = temp(3:length(temp)-2)
var_cell{n,m} = temp2
于 2013-05-18T13:20:11.417 回答
0

要删除外部引号,请应用于regexprep您的单元格数组(让我们表示它C):

regexprep(C, '^\s*''\s*(.*)\s*''\s*', '$1');

P. S:
您最好先阅读没有这些引号的输入文件。

于 2013-05-18T19:15:33.063 回答