2
我正在尝试编写一个函数,将每个单元格数组中的每个事物的类,长度和值放入一个结构体中,但我一直收到开关语句的错误Matlab开关壳
function [ out, common ] = IDcell(cA)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
cl={};
val={};
len={};
for x=1:length(cA)
switch cA(x)
case isnum
cl(x)='double';
case ischar
cl(x)='char';
case islogical
cl(x)='logical';
case iscell
cl(x)= 'cell';
end
val=[val cA{x}];
len=[len size(value(x))];
end
out=struct('value', val, 'class', cl, 'length', len);
end
[out]=IDcell(cA)
SWITCH expression must be a scalar or string constant.
Error in IDcell (line 8)
switch cA(x)
当然,Matlab提供的'class'函数几乎可以代替他的整个代码 – 2012-04-27 18:22:52