Matlab 更改cellstr中类的名称

Matlab 更改cellstr中类的名称,matlab,Matlab,例如,类的类型是apple、orange和grape。 现在我在matlab代码中使用apple作为类,如何在cellstr中将类从apple更改为orange,而不将单词“apple”逐个更改为“orange” class=[cellstr('apple');cellstr('apple');cellstr('apple');cellstr('apple')]; 这意味着我只需键入一个类,如orange,它将创建一个新类,如下所示 class=[cellstr('orange');cell

例如,类的类型是apple、orange和grape。 现在我在matlab代码中使用apple作为类,如何在cellstr中将类从apple更改为orange,而不将单词“apple”逐个更改为“orange”

class=[cellstr('apple');cellstr('apple');cellstr('apple');cellstr('apple')];
这意味着我只需键入一个类,如orange,它将创建一个新类,如下所示

 class=[cellstr('orange');cellstr('orange');cellstr('orange');cellstr('orange')];

class
是函数名,不要将其用作变量名

>> c = repmat({'apple'}, 4, 1)

c = 

    'apple'
    'apple'
    'apple'
    'apple'

>> b = strrep(c, 'apple', 'orange')

b = 

    'orange'
    'orange'
    'orange'
    'orange'