フィルターのクリア

ho to change cell array elemen value to Nan, when using gpuarray?

2 ビュー (過去 30 日間)
Mantas Vaitonis
Mantas Vaitonis 2018 年 6 月 19 日
コメント済み: Mantas Vaitonis 2018 年 6 月 19 日
Hello Everyone,
Maybe somebody has a solution for this case? I have gpu cellarray with 1x499 and cells within 5x5. I would like to find zeros and change them to Nan. What I managed to do is here:
SQ=cellfun(@(x)(x==0,NaN,x), SQ,'UniformOutput',false);
  1 件のコメント
Mantas Vaitonis
Mantas Vaitonis 2018 年 6 月 19 日
Did change code a bit:
SQ(cellfun(@(x) x == 0, SQ{:, :}, 'UniformOutput', false)) = {NaN};
However, didi receive this error: Error using cellfun Input #2 expected to be a cell array, was gpuArray instead.

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

採用された回答

Edric Ellis
Edric Ellis 2018 年 6 月 19 日
Instead of a 1x499 cell array of 5x5 gpuArray matrices, why not consider a 5x5x499 array. You can convert your existing cell array like this:
SQ_array = cat(3, SQ{:}); % concatenate in 3rd dimension, result is 5x5x499
Then, you can simply do:
SQ_array(SQ_array == 0) = NaN;
To do this using cellfun, the simplest way is to use standardizeMissing:
cellfun(@(x) standardizeMissing(x, 0), SQ, 'UniformOutput', false)
  3 件のコメント
Edric Ellis
Edric Ellis 2018 年 6 月 19 日
You can use mat2cell, like this:
mat2cell(SQ_array, 5, 5, ones(1, 499))
but really, I suspect you'd be much better off retaining the array form if you can. A 5x5 matrix is usually much too small for the GPU to offer much benefit - you need to keep your GPU busy by feeding it lots of data all at once in a single array-based operation. You've got a much better chance with a 5x5x499 array.
Mantas Vaitonis
Mantas Vaitonis 2018 年 6 月 19 日
Ok, thank You, will try with 3D.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGPU Computing in MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by