How do you write a string inside a cell ?

4 vues (au cours des 30 derniers jours)
Marco
Marco le 12 Déc 2012
Hi,
I have a empty 2x2 cell C since
C = cell(2,2);
Now, I have 2 strings to put as 1st column of C, they are:
'String 1'
and
'String 2'
but when I write:
C{:,1} = {'String 1' ; 'String 2'}
It returns the error:
The right hand side of this assignment has too few values to satisfy
the left hand side.
Can't I write inside a cell like an array as above ?
(in array in matlab as above C(:,1) = [2;3]; is allowed)

Réponse acceptée

Walter Roberson
Walter Roberson le 13 Déc 2012
C(:,1) = [{'String 1'}; {'String 2'}];
  1 commentaire
Jan
Jan le 13 Déc 2012
Or:
C(:,1) = {'String 1'; 'String 2'}

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by