How to remove range of values / keep range of values from double
4 ビュー (過去 30 日間)
古いコメントを表示
I have a 1201x1201 dataset, and I'm looking to remove all values outside my range (A-B). It will be used in a contour3 and surfc.
Here's the relevant section of code:
[X,Y] = meshgrid (105:1/1200:106,-7.25:1/1200:-6.25);
axis equal
% z = s( s>=200 & s<=500 ); - the code I've been trying to make work, but this makes my 1201x1202 double a 45221x1 double, so won't plot with contour3
contour3(X,Y,z)
surfc(X,Y,z, 'edgecolor', 'none');
's' is the original 1201x1201 dataset that i want to remove all values outside the (A-B) range from.
Matlab2020b
回答 (1 件)
Walter Roberson
2021 年 2 月 16 日
s = sort(randn(128, 160));
mask = s < -1.5 | s > 2.2;
Al = double(~mask); %need 1 for visible, 0 for invisible
surf(s, 'edgecolor', 'none', 'alphadata', Al, 'facecolor', 'interp', 'facealpha', 'interp')
3 件のコメント
Walter Roberson
2021 年 2 月 16 日
I seem to be having trouble getting this to work the way I expect. I will get back to it after I have some sleep.
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!