MATLAB打印出一串字符串?

时间:2022-12-14 18:23:37

having trouble with the following code which I thought would work:

我认为以下代码有问题:

OriginalSamples = {'BeforeWeDepart','ImSoGlad','NotToday', 'WellNowYouKnow'};
numOriginalSamples = length(OriginalSamples);

for i=1:numOriginalSamples
    disp(OriginalSamples(i));
end

Error I get is:

我得到的错误是:

Error using ==> vertcat
CAT arguments dimensions are not consistent.

How to do this simple operation?

怎么做这个简单的操作?

Thanks.

1 个解决方案

#1


2  

Try to change disp(OriginalSamples(i)) to disp(OriginalSamples{i})

尝试将disp(OriginalSamples(i))更改为disp(OriginalSamples {i})

Indexing with () returns a cell array, while indexing with {} return the content of the cell

使用()索引返回一个单元格数组,而使用{}索引则返回单元格的内容

#1


2  

Try to change disp(OriginalSamples(i)) to disp(OriginalSamples{i})

尝试将disp(OriginalSamples(i))更改为disp(OriginalSamples {i})

Indexing with () returns a cell array, while indexing with {} return the content of the cell

使用()索引返回一个单元格数组,而使用{}索引则返回单元格的内容