GorillaApe
GorillaApe

Reputation: 3641

Matlab string array

All i am trying to do is this:

    type = cell(size(A));
    ...
    i = find(A == 0);
    type{i} = 'pasok';

However it miserably fails is size(A) > 1 or if i is empty. Is there any workaround for this problem?

UPDATE -ERROR

type =

[]    []

ans =

 1     2

i =

 1     2

The right hand side of this assignment has too few values to satisfy the left hand side.

Error in ellipse (line 48) type{i} ='pasok';

Upvotes: 1

Views: 263

Answers (1)

H.Muster
H.Muster

Reputation: 9317

To assign one value to multiple cell-entries at once, you can use

[type{i}] = deal('pasok');

Note that type{i} has to be in square brackets.

Upvotes: 2

Related Questions