How to remove range of values / keep range of values from double

조회 수: 4 (최근 30일)
Ishaan Chauhan
Ishaan Chauhan 2021년 2월 16일
댓글: Ishaan Chauhan 2021년 2월 16일
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
  댓글 수: 2
Ishaan Chauhan
Ishaan Chauhan 2021년 2월 16일
Alternatively, I'd like to be able to keep the data, but highlight the values in my range (A-B)
Ishaan Chauhan
Ishaan Chauhan 2021년 2월 16일
EDIT:
I've found a different method that just adjusts the range displayed and highlighted, but still provides the required outcome on my 3d plot.
caxis([A B])

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
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
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.
Ishaan Chauhan
Ishaan Chauhan 2021년 2월 16일
No worries Walter,
I've found an easier method that suits my needs anyway. Instead of editing the data directly and opening a can of worms there, I've just changed the way it's displayed using caxis
Best, and thank you for your help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by