在MATLAB中,可以使用花括号 {} 来提取 cell 数组中的数据。下面是一些示例代码,展示了如何提取 cell 数组中的数据:
% 创建一个 cell 数组cellArray = {'apple', 123, [1 2 3], magic(3)};% 提取 cell 数组中的数据data1 = cellArray{1}; % 提取第一个元素,结果为字符串 'apple'data2 = cellArray{2}; % 提取第二个元素,结果为数值 123data3 = cellArray{3}; % 提取第三个元素,结果为矩阵 [1 2 3]data4 = cellArray{4}; % 提取第四个元素,结果为 3x3 的魔方阵% 打印提取的数据disp(data1);disp(data2);disp(data3);disp(data4);运行上述代码,将会得到以下输出:
apple1231 2 38 1 63 5 74 9 29 6 47 3 52 7 96 4 8通过这种方式,你可以根据索引提取 cell 数组中特定位置的数据。请注意,使用花括号 {} 提取 cell 元素时,会返回元素的原始类型,而不是以 cell 的形式返回。

