From: Judas Magnus on
Say that I have a cell array

cell1 = (5,5)
I want to fill all the containers with the number "1". How can I do this, also if there was a name inside one of the containers then is it possible to check to see if there is an empty container and assign "1" to all of them?
From: us on
"Judas Magnus" <ragnaork5435(a)yahoo.com> wrote in message <hpampd$1fv$1(a)fred.mathworks.com>...
> Say that I have a cell array
>
> cell1 = (5,5)
> I want to fill all the containers with the number "1". How can I do this, also if there was a name inside one of the containers then is it possible to check to see if there is an empty container and assign "1" to all of them?

one of the solutions

c=cell(5,5);
c(1,1)={'a'};
c(2,2)={'b'};
ix=cellfun('isempty',c);
c(ix)={'1'}
%{
% c =
'a' '1' '1' '1' '1'
'1' 'b' '1' '1' '1'
'1' '1' '1' '1' '1'
'1' '1' '1' '1' '1'
'1' '1' '1' '1' '1'
%}

us
From: Kirill on
On Apr 4, 2:46 pm, "Judas Magnus" <ragnaork5...(a)yahoo.com> wrote:
> Say that I have a cell array
>
> cell1 = (5,5)
> I want to fill all the containers with the number "1". How can I do this, also if there was a name inside one of the containers then is it possible to check to see if there is an empty container and assign "1" to all of them?

cell1 = cell(5,5);
cell1(:) = {'string'}
From: Judas Magnus on
hmmm is there a way to AFTER filling all the containers with "1"
to replace all of them with the word "cool" ?

for example:

cf = cellstr(char('Meat','Meatz','Meat1','Meat2','Meat3'))
c = cell(5,5)
r = randperm(numel(c));
r = r(1:numel(cf));
c(r) = cf(randperm(numel(cf)))

%I want to replace all those of meat in the cf array to be replaced by "cool"
From: Kirill on
If you use '' for empty cell elements and run regexprep() on cell
array, it should work:

clc

cf = cellstr(char('Meat','Meatz','Meat1','Meat2','Meat3'));
c = cell(5,5)
c(:)= {''}; %!!!
r = randperm(numel(c));
r = r(1:numel(cf));
c(r) = cf(randperm(numel(cf)))

%I want to replace all those of meat

c1 = cellfun(@(c) regexprep(c, '^Meat$', 'cool'), c, 'UniformOutput',
0) %!!!

Kirill