I have a data matix of 84761 x 8 (an example is attached: EditedWindTempMatrix_eg.txt).
I would like to remove the rows that have any NaNs in and re-write the rows with no NaNs to a new matrix (QCMat).
I have used 'isfinite' to determine where there is data. This returns a 84761 x 8 logical matrix (an example is attached: idx_eg.txt)
When I run the script, I receive an error (Subscripted assignment dimension mismatch.) associated with line:
QCMat(Rowassign,:)=EditedWindTempMatrix(i,:);
How do I assign the rows of data to the new matrix?
Thank you, Jenny
%%remove the NaNs from the data and write out the data to a new matrix QCMat
idx = isfinite(EditedWindTempMatrix); % returns a matrix with 8 columns with 1 = true; 0 = false
% Check each row of data to see whether it has data - using isfinite - and write the rows with data to a new matrix
[NrRows, NrCols]=size(EditedWindTempMatrix);Rowassign=1;for i = 1:NrRows; Datacheck=sum(idx(i,:)); % add the results along a row from the isfinte command. If the ans <NrCols then there is a NaN in that row so we leave it out of the new matrix.
if Datacheck==NrCols; QCMat(Rowassign,:)=EditedWindTempMatrix(i,:); Rowassign=Rowassign+1; endend
Best Answer