小编ram*_*ker的帖子

Matlab开关盒

我正在尝试编写一个函数,将单元格数组中每个东西的类,长度和值放入结构中,但是我一直在使用switch语句出错

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)
Run Code Online (Sandbox Code Playgroud)

matlab switch-statement

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

matlab ×1

switch-statement ×1