# How to add values into rows of cell array?

10 views (last 30 days)
Titus Priscu on 19 May 2022
Edited: David Hill on 19 May 2022
Currently I have a cell array that has around about 6 entries that are each a matrices
What I want to do is add values into rows 2,3,4 for each column, how would I go about doing this?
Any help is appreciated :)
##### 6 CommentsShowHide 5 older comments
Titus Priscu on 19 May 2022
ok so what I am doing is taking some pictures from an ultrasound and the data is kept as a matrix in the first row ( the 3x18 doubles). Each cell in the row corresponds to 1 picture. so I have 6 pictures and now what i want to do is add to the cell array each pictures coordinates (x,y,z) with the 2nd row being x, 3rd row being y and 4th row being z. What Im having trouble doing is making a program to the coordinates into the cell array. To show what I want I made a basic drawing in excel in the image below. The red values are arbitrary at the moment and what I want to be able to do is just manually put values into the cell aray in rows 2,3,4 where the red numbers are. Hope this helps explain what im looking for, thanks again for all the help.

Sign in to comment.

### Answers (1)

David Hill on 19 May 2022
Edited: David Hill on 19 May 2022
Assuming the values to be added are in a matrix (3x6)
for k=1:6
yourCell{k}=randi(256,3,18)-1;%populate yourCell
end
valueAdded=randi(100,3,6);%populate x,y,z values to add
newCell=cell(4,6);
newCell(1:4:end)=yourCell;
for k=1:6
for m=2:4
newCell{4*(k-1)+m}=valueAdded(m-1,k);
end
end
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by