Excluding NaNs in resize

Hi
I want to resize 2 arrays, A and B, to make them the same size.
BUT, array B has a lot of NaN value.
So, I only want to resize A to fit the numerical data in B, excluding the NaN values.
% The CODE to resize
C = imresize(A, size(B));
% How can I modify the size(B) part to exclude the NaN during the resize process?

回答(1 个)

KSSV
KSSV 2020-4-22

0 个投票

You can fill the NaN's using fillmissing. And then use resize the way you want.
You can use interp2 to get them to the same size.

5 个评论

SuzieChan
SuzieChan 2020-4-22
编辑:SuzieChan 2020-4-22
Hi. I want to ignore NaN. I don't want to fill them.
You have entire rows and columns as NaN?
Yes. I literally want the imresize to ignore the NaN data in B when resizing image A, so the data in A are only resized onto numerical data in B.
SuzieChan
SuzieChan 2020-4-22
编辑:SuzieChan 2020-4-22
I could convert the NaN to 0 and maybe there is some code to ignore the 0 when doing the imresize?
Remove rows and columns with NaN.
A(all(isnan(A),2),:) = [] ; % remove in NaN's rows
A(all(:,isnan(A),1)) = [] ; % remove rows in columns

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

提问:

2020-4-22

评论:

2020-4-22

Community Treasure Hunt

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

Start Hunting!

Translated by