Reputation: 1
I have cell of cell with name TEMP(1x4)
. Each cell of cell has TEMP{1}
to Temp{4}
different set of values. Eg.
TEMP{1} =1:10
TEMP{2} =1:20
TEMP{3} =1:30
...
Now I have created a new cell lets name NEWTEMP={ 11 , 12, 13}
. I want to concatenate NEWTEMP
values with TEMP{1}
such that now TEMP{1}= 1:13
. How can I do it easily.
I need TEMP{1}
and NEWTEMP
values to be concatenated in a single cell (i.e. in TEMP{1}
)
Upvotes: 0
Views: 40
Reputation: 191
I think you meant to do
NEWTEMP = {[11,12,13]}
not
NEWTEMP = {11,12,13}
Look carefully at the difference between the two, the first is a 1x1 cell array containing a 1x3 numeric array
The second is a 1x3 cell array containing a 3 1x1 numeric arrays
If you use the first example, then concatenation is completed like this:
TEMP{1} = [TEMP{1} cell2mat(NEWTEMP)]
Upvotes: 0
Reputation: 1351
You could do it this way:
temp = cell(4,1);
for i = 1:4
temp{i} = 1:i*10;
end
newtemp = {};
newtemp{1} = 11:13;
temp{1} = [temp{1} newtemp{1}];
Upvotes: 1