필터 지우기
필터 지우기

How to zero the data points behind the line of figure?

조회 수: 2 (최근 30일)
Smithy
Smithy 2021년 1월 28일
댓글: KSSV 2021년 1월 28일
I have a figure of plot3 and I would like to making the data contacting the blue line to zero.
How to zero the data points behind (contacting) the line..
clear all;clc;close all;
data = ones(100,200);
x = (0:1:size(data,2)-1)*0.1;
y =(0:1:size(data,1)-1)*0.1;
surf(x,y,data*100); hold on;
grid off;
colorbar;
view([0 90])
shading interp;
set(gca,'xlim',[min(x)-2 max(x)+2],'ylim',[min(y)-2 max(y)+2])
x = [2.4;13.9];
y = [-0.5;9.8];
plot3(x,y,1000*ones(length(x),length(y)),'b','LineWidth',10)

채택된 답변

KSSV
KSSV 2021년 1월 28일
편집: KSSV 2021년 1월 28일
data = ones(100,200);
x = (0:1:size(data,2)-1)*0.1;
y =(0:1:size(data,1)-1)*0.1;
x1 = [2.4;13.9];
y1 = [-0.5;9.8];
p = polyfit(x1,y1,1) ;
x2 = x ;
y2 = polyval(p,x2) ;
[X,Y] = meshgrid(x,y) ;
idx = knnsearch([X(:) Y(:)],[x2' y2']) ;
data(idx) = 0 ;
surf(x,y,data*100); hold on;
grid off;
colorbar;
view([0 90])
shading interp;
set(gca,'xlim',[min(x)-2 max(x)+2],'ylim',[min(y)-2 max(y)+2])
% plot3(x1,y1,1000*ones(length(x1),length(y1)),'b','LineWidth',10)
  댓글 수: 2
Smithy
Smithy 2021년 1월 28일
편집: Smithy 2021년 1월 28일
Thank you very much for your kind answer. I think that the answer is not the case for my question.
I hope to make the "data = ones(100,200);" contated line to zero.
Is there any hints or helps?
KSSV
KSSV 2021년 1월 28일
Edited the answer.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by