输出多元胞数组的内容
outputting contents of multiple cell array
我按如下方式连接元胞数组:
数据 = {5x1 单元格} {1x1 单元格} {0x1 单元格}
这个命令,数据{:},给我:
ans =
'MR619_01_XR'
'MR629_01_XR'
'MR639_01_XR'
'MR645_01_XR'
'MR659_01_XR'
ans =
'MR511_01_XR'
ans =
Empty cell array: 0-by-1
如何使用for循环或其他方法输出如下内容:
MR619_01_XR
MR629_01_XR
MR639_01_XR
MR645_01_XR
MR659_01_XR
MR511_01_XR
NULL
谢谢
temp=cellfun(@isempty,data); %Finding where empty elements are
data(temp)={'NULL'}; %Changing those indexes with 'NULL'
req = vertcat(data{:}) %Concatenating vertically
%For your data, it gives:
%req =
% 'MR619_01_XR'
% 'MR629_01_XR'
% 'MR639_01_XR'
% 'MR645_01_XR'
% 'MR659_01_XR'
% 'MR511_01_XR'
% 'NULL'
我按如下方式连接元胞数组:
数据 = {5x1 单元格} {1x1 单元格} {0x1 单元格}
这个命令,数据{:},给我:
ans =
'MR619_01_XR'
'MR629_01_XR'
'MR639_01_XR'
'MR645_01_XR'
'MR659_01_XR'
ans =
'MR511_01_XR'
ans =
Empty cell array: 0-by-1
如何使用for循环或其他方法输出如下内容:
MR619_01_XR
MR629_01_XR
MR639_01_XR
MR645_01_XR
MR659_01_XR
MR511_01_XR
NULL
谢谢
temp=cellfun(@isempty,data); %Finding where empty elements are
data(temp)={'NULL'}; %Changing those indexes with 'NULL'
req = vertcat(data{:}) %Concatenating vertically
%For your data, it gives:
%req =
% 'MR619_01_XR'
% 'MR629_01_XR'
% 'MR639_01_XR'
% 'MR645_01_XR'
% 'MR659_01_XR'
% 'MR511_01_XR'
% 'NULL'