MATLAB Answers

HOw do i copy a particular 4x4 cell aray into a 5x5 cell array?

2 views (last 30 days)
sachin narain
sachin narain on 13 Jun 2018
Answered: Gayatri Menon on 26 Jun 2018
I have a 5x5 cell array 'raw_Grounds'.I have another cell array with size 4x4 with some datas in it. If you notice the data picture attached , it contains the same data like the raw grounds from 2,2 cell to the end(with an edited values)
What i need to do is,copy the datas line by line from cell array 'data' to Raw Grounds. THe 1st column of raw_grounds remains unchanged .Only the dats get copy pasted from the 2nd column. ALso to note is,while copying line by line on to the raw_Grounds,the code must skip empty rows.
Raw Grounds contains 1st row with NaN values(shown in the picture attached)
Kindly help me with this.Hpoe the Question is clear.Seeing the pictures attached will make it more clear

  0 Comments

Sign in to comment.

Answers (1)

Gayatri Menon
Gayatri Menon on 26 Jun 2018
Hi,
Hope this example script helps you. Here I have created 2 cell arrays, excel and data. The first line of excel cell array contains 'NaN' values. I can replace the rest of the lines with the values from data cell array using the following code snippet:
% creating two sample cell arrays
excel={'test1',NaN,NaN;'test2','a',1;'test3','b',2}
data={'a_new',1.5; 'b_new' 2.5;}
% replacing the values of excel excluding 1st coloumn and and 1st row
excel(2:3,2:3)=data
Regards,
Gayatri

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags