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

조회 수: 2 (최근 30일)
sachin narain
sachin narain 2018년 6월 13일
답변: Gayatri Menon 2018년 6월 26일
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

답변 (1개)

Gayatri Menon
Gayatri Menon 2018년 6월 26일
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

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by