I'm trying to convert
53 96 87
48 94 NaN
49 95 NaN
51 98 NaN
52 99 NaN
55 100 NaN
to
1 2 3
1 2 NaN
1 2 NaN
1 2 NaN
1 2 NaN
1 2 NaN
The best I can do is this, which of course fills each column (including the NaNs).
for a = 1:size(y,2)
for b = a
y(:,a) = b;
end
end
If anyone could point me toward a function that could work that would be very helpful. I've tried ~isnan(y) and others but they only allow one input argument.

 採用された回答

James Tursa
James Tursa 2014 年 7 月 22 日

0 投票

E.g.,
y = floor(rand(6,3)*100);
y(2:6,3) = nan; % test data
z = repmat(1:size(y,2),size(y,1),1);
z(isnan(y)) = nan;

1 件のコメント

Scott
Scott 2014 年 7 月 22 日
That's clever. I'll have to add repmat to my small repertoire. Thanks a lot, James :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation of 2-D Selections in 3-D Grids についてさらに検索

製品

タグ

質問済み:

2014 年 7 月 22 日

コメント済み:

2014 年 7 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by