I have a excel file with data as shown,
Time Exp1 Exp20.1 26 9650.2 23 9660.3 25 9630.4 NA 9560.5 24 9510.6 26 944
Now I want to write the processed data (replacing the NA with the average of previous and next cell) with the header to an excel file as shown below
Time Exp1 Exp20.1 26 9650.2 23 9660.3 25 9630.4 24.5 9560.5 24 9510.6 26 944
I have used the code,
[num, text] = xlsread('test.xlsx');numfill = fillmissing(num,'linear'); % fill missing cells, replaces NA with the average of previous and next cell
text1=text(1,:); % since the text has "NA" strings as well
T = [numfill ; text1]
when I read the excel initially using the below mentioned code,
[num, text] = xlsread('test.xlsx');
"NA" in the excel is also considered as a string as shown below,
text = 5×3 cell array
'Time' 'Exp1' 'Exp2' '' '' '' '' '' '' '' '' '' '' 'NA' ''
That is the reason I have used this
text1=text(1,:); % to consider only the first row of the array.
But when I run the code I get the error,
Error using vertcat Dimensions of matrices being concatenated are not consistent.Error in Untitled3 (line 5) T = [numfill ; text1]
Please let me know what am I doing wrong?
Thanks
Best Answer