How do i copy a one matrix into another ignoring the ''NAN' elements in the matrix?
I have a cell array "raw_Grounds" which is constructed in such a way that for some rows the entire row values from the 2nd column to the end would be 'NaN' i.e. for example in the 3rd row, raw_Grounds(3,2:end) would completly be 'NaN' (as can be seen from the code snippet below.)
i have a 2nd cell array "dataArr". The sizes of "dataArr" and "raw_Grounds" are related such that if the size of "raw_Grounds" is 7x5 (mXn) in which two rows have 'NaN' values as mentioned above, the size of "dataArr" would be 5x4. i.e size of "dataArr" is [(m-no.of NaN row)x(n-1)]
Now, i have to create a 3rd cell array "newRaw_Grounds" by copying the data from "dataArr" to "raw_Grounds" such that the data from "dataArr" fill the non 'NaN' rows of "raw_Grounds".
For eg: if the 3rd and the 5th row of "raw_Grounds"(7x5) have 'NaN' values from (3,2:end) and (5,2:end) respectively, the data from the 1st and 2nd row of "dataArr" should fill the (1,2:end) and (2,2:end) of "newRaw_Grounds", (4,2:end) of "newRaw_Grounds" should be filled with the data from the 3rd row of "dataArr" and (6,2:end) and (7,2:end) row of "newRaw_Grounds" should be filled with the 4th and 5th row values of "dataArr". The values in (3,2:end) and (5,2:end) of "newRaw_Grounds" should be 'NaN' just like in "raw_Grounds "
The first column of "newRaw_Grounds" the same as teh first column of "raw_Grounds".
THe problem is a bit complicated like you can see, but any help on this would be of real help for me. I have attached 3 sample matrices below for better comprehension of the scenario.
Thanks in advance,
raw_Grounds = { ['sfsdfgdsfgdsgdsfg'] '0.556' '0.455' '0.235' '0.5789' ['sfsdfgdsfgdsgdsfg'] [ 201] [ 3011] [ 40111] [ 50311] ['sfsdfgdsfgdsgdsfg'] [ NaN] [ NaN] [ NaN] [ NaN] ['sfsdfgdsfgdsgdsfg'] '0.5' '0.5' '0.5' '0.5' ['sfsdfgdsfgdsgdsfg'] [ NaN] [ NaN] [ NaN] [ NaN] ['sfsdfgdsfgdsgdsfg'] [ 1] [ 1] [ 1] [ 1] ['sfsdfgdsfgdsgdsfg'] 'Asphalt' 'Concrete' 'Grass' 'Cobblestone'};
data = { '0.0515' '0.4546' '0.5ez' '0.5gf' '7891' '2650' '1874' '1369fd' '0.5' '0.6' '0.5' '0.75' '1' '20' '1' '100' 'Asphalt' 'Asphalt' 'Asphalt' 'Asphalt'};
newRaw_Grounds ={ ['sfsdfgdsfgdsgdsfg'] '0.0515' '0.4546' '0.5ez' '0.5gf' ['sfsdfgdsfgdsgdsfg'] '7891' '2650' '1874' '1369fd' ['sfsdfgdsfgdsgdsfg'] [ NaN] [ NaN] [ NaN] [ NaN] ['sfsdfgdsfgdsgdsfg'] '0.5' '0.6' '0.5' '0.75' ['sfsdfgdsfgdsgdsfg'] [ NaN] [ NaN] [ NaN] [ NaN] ['sfsdfgdsfgdsgdsfg'] '1' '20' '1' '100' ['sfsdfgdsfgdsgdsfg'] 'Asphalt' 'Asphalt' 'Asphalt' 'Asphalt'};
댓글 수: 2
답변 (1개)
참고 항목
카테고리
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!