JDS
JDS

Reputation: 16978

MATLAB printing out a list of strings?

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.

Upvotes: 0

Views: 67

Answers (1)

KlausCPH
KlausCPH

Reputation: 1835

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

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

Upvotes: 2

Related Questions