Function which creates a vertical line (Heaviside or something) which has a double gap in it

조회 수: 2 (최근 30일)
I want to create a function which produces something like this where we have a vertical line which has a gap in it.
https://i.stack.imgur.com/uKcqG.png
I have a feeling it'll involve heaviside functions but I'm not sure
  댓글 수: 5
John D'Errico
John D'Errico 2023년 1월 4일
No. Sorry, but this is not a function at all, in the sense that it is a single valued function that will return a single result. In fact, it would not use a heaviside function either. Simplest would be to just use direct calls to a tool like line or plot to draw the lines you want. That is, do exactly as shown by @Dyuman Joshi, in what should have been an answer.
You could call it an implicit function, but doing so is a hack that I'm not even terribly proud to have written:
fun = @(x,y) ((x - 0.5).*((y > 1) | (y < -1))) .* ((x + 0.5).*((y > 1) | (y < -1)));
fimplicit(fun,[-12,12,-12,12])
Follow the advice of @Dyuman Joshi.
John D'Errico
John D'Errico 2023년 1월 4일
@HC98 Sorry, but what you want is not a (usable) function, at least not a single valued function. For some value of x, what is y?

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

답변 (1개)

Johannes Hougaard
Johannes Hougaard 2023년 1월 4일
I think this function will do what you like.
For your example you should put in approximately
x = 0.1;
gaps = [-1.1 -1;1 1.1];
width = 0.1;
But as I don't have your code for the remainder of the graph I've tested using the contourf(peaks) test code
fig_handle = figure;
axes_handle = axes;
contourf(peaks);
x = 18;
gaps = [15.1 16.5;19.2 20.6];
linewidth = 0.2;
vertical_gapped_line(axes_handle,x,gaps,linewidth);

카테고리

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

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by