user3889224
user3889224

Reputation:

Removing Columns containing NaN and corresponding column in other matrix

I have following problem:

I want to:

No idea how to do that... For deleting the columns with NaN I used

CompanyDataTimeWindow = estPer3(:,isfinite(sum(estPer3)))

However I have no idea how to delete corresponding column in B

Upvotes: 2

Views: 2494

Answers (2)

lakshmen
lakshmen

Reputation: 29064

[rows, cols] = find(isnan(A)); 
A(:,unique(cols)) = [];
B(:,unique(cols)) = [];

Upvotes: 1

ThP
ThP

Reputation: 2332

This should work:

NaNCols = any(isnan(A));
A = A(:,~NaNCols)
B = B(:,~NanCols)

Upvotes: 4

Related Questions