フィルターのクリア

For loop not stopping

1 回表示 (過去 30 日間)
Hrvoje Lukacic
Hrvoje Lukacic 2022 年 12 月 1 日
コメント済み: Hrvoje Lukacic 2022 年 12 月 1 日
Hi! I have a raster file in tiff format which has some values set to -9999. I wrote a small code that should replace all -9999 values with NaN. Whren I execute the code the loop just keeps on going and it wont stop and generate the result. Can you please hel me figure out why? I am not attaching the raster because it is to big.
%reading Raster Input data from a file
[aspect, A] =readgeoraster('Aspect_0,5m.tif');
[slope, A] = readgeoraster('Slope_0,5m.tif')
imagesc(aspect)
%reading csv Input data from a file
discontinuity_orientations =readtable('orientations.xlsx') ;
for i =1:size(aspect,1)
if aspect (i,1)==-9999
aspect (i,1) = NaN
end
end

採用された回答

David Hill
David Hill 2022 年 12 月 1 日
Instead of a for-loop, just do it all at once.
idx=aspect(:,1)==-9999;
aspect(idx,1)=nan;
  1 件のコメント
Hrvoje Lukacic
Hrvoje Lukacic 2022 年 12 月 1 日
Thank you for your answer !! But just in case, how to I make a for loop which goes from element to element and does some operation?

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

その他の回答 (1 件)

VBBV
VBBV 2022 年 12 月 1 日
編集済み: VBBV 2022 年 12 月 1 日
if ismember(-9999,aspect(i,1))
Check using ismember

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by