How to add a more element in an existing cell array in specific positions?
Show older comments
Hi, The problems starts like this.
I have a cell array named: FlowRate = cell(1,16);
Initially,
Flow =
[498,1] [398,3] [343,1] [840,3] [899,2] [792,2] [828,4] [440,2] [812,5] [395,4][495,5] [792,1] [876,5] [563,5] [629,1] [280,3]
After some calculation I get an array: l =[3 4 10 16], I have to make add this value [490,1] to cell position mentioned in 'l'.
So, the solution should be:
New_Flow =
[498,1] [398,3] [343,1;490,1] [840,3;490,1] [899,2] [792,2] [828,4] [440,2] [812,5] [395,4;490,1][495,5] [792,1] [876,5] [563,5] [629,1] [280,3;490,1]
I would be grateful to get your support. Than You.
Accepted Answer
More Answers (1)
Walter Roberson
on 10 Nov 2015
what_to_add = [490,1];
for K = I
New_Flow{K} = [New_Flow{K}, what_to_add];
end
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!