Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 将MATLAB字符数组转换为字符串_String_Matlab_Char - Fatal编程技术网

String 将MATLAB字符数组转换为字符串

String 将MATLAB字符数组转换为字符串,string,matlab,char,String,Matlab,Char,从MATLAB字符数组开始,一个: A(1,1) = 'A' A(1,2) = 'P' A(1,3) = 'R' A(2,1) = 'M' A(2,2) = 'A' A(2,3) = 'Y' 如何将其转换为字符串单元格B,以便: B{1} = 'APR' B{2} = 'MAY' 编辑: A是一个单元格,使用函数cellstr会给出错误 Error using cellstr (line 23) S must be 2-D. Error using cellstr (line 23) S

从MATLAB字符数组开始,一个:

A(1,1) = 'A'
A(1,2) = 'P'
A(1,3) = 'R'
A(2,1) = 'M'
A(2,2) = 'A'
A(2,3) = 'Y'
如何将其转换为字符串单元格B,以便:

B{1} = 'APR'
B{2} = 'MAY'
编辑: A是一个单元格,使用函数cellstr会给出错误

Error using cellstr (line 23)
S must be 2-D. 
Error using cellstr (line 23)
S must be 2-D.

使用以下功能:

对于3D字符数组T

B = cellstr(T(1,:,:))
给出了错误

Error using cellstr (line 23)
S must be 2-D. 
Error using cellstr (line 23)
S must be 2-D.
相反,首先将其分配给2D矩阵,然后按照Franck的建议使用“cellstr”

A(:,:) = T(1,:,:)
B = cellstr(A)

您的错误消息中的是谁?我有A=data{3,1}(一些单元格数据),因此A现在是A。然后我输入B=cellstr(A),我得到了错误。你能把数据放在问题中还是放在pastebin上?还有,cellstr对A有效吗?在尝试粘贴我的数据时,我似乎找到了解决办法。起初,我的数据是一个月内的成对数据。然后我尝试使用cellstr(T(1,:,:))导致上述错误。然而,当我分配A(:,:)=T(1,:,:)并执行cellstr(A)时,它工作了。