I have a 1D logical vector, a cell array, and a string value I want to assign.
I tried "cell{logical} = string" but I get the following error:
The right hand side of this assignment has too few values to satisfy
the left hand side.
Do you have the solution?
You don't actually need to use deal
.
a = cell(10,1); % cell array
b = rand(1,10)>0.5; % vector with logicals
myString = 'hello'; % string
a(b) = {myString};
Looking at the last line: on the left hand side we are selecting a subset of cells from a
and saying that they should all equal the cell on the right hand side, which is a cell containing a string.