필터 지우기
필터 지우기

Selecting points from UI Axes App Designer MATLAB R2019a

조회 수: 27 (최근 30일)
Hemanth Hariharan
Hemanth Hariharan 2019년 8월 12일
댓글: Ahmed 2023년 6월 7일
I am plotting this histogram on UI Axes App Designer R2019a, and I want the user to be able to interactively split the plot using vertical lines (so that I can get the X coordinate at which they are placed). I was previously using getpts, which does not seem to work on UI Axes. Is there a solution for this?

채택된 답변

Abhilash Padma
Abhilash Padma 2019년 8월 16일
I understand that you want to split the plot using vertical lines whenever you click on the axes. But, there is no built-in functionality of adding callbacks to UIAxes as of now. Rather, consider using the ButtonDownFcn callback of plot object to draw vertical lines. Here, the plot object can be used to get your expected output.The following code below may help you solve the problem.
p=plot(app.UIAxes,1:10);
p.ButtonDownFcn=@mouseClick;
function mouseClick(~,~)
cp=get(app.UIAxes,'CurrentPoint');
xline(app.UIAxes,cp(1,1));
end
  댓글 수: 5
Prashanth Thambala
Prashanth Thambala 2022년 9월 22일
@Abhilash Padma can you help me to break out of the function, as the function does not run for finite clicks and stores the last clicked value
Ahmed
Ahmed 2023년 6월 7일
Hello everyone,
I'm also struggling with this. Where should the function (mouseclick) be placed in the code view? I have the similar implementation but my click function doesnt seem to be triggered when I click on the plot. I think the reason is becuase it is in another slider function. So I'm not sure now where to place in my click function in the code view.
% Value changed function: FrequencySlider
function FrequencySliderValueChanged(app, event)
value = app.FrequencySlider.Value;
freq=value;
[d,ix]=min(abs(app.freq_vec-freq));
scatter3(app.UIAxes,app.XYZ(:,1)*10000,app.XYZ(:,2)*10000,abs(app.y(:,ix))*10000,[],abs(app.y(:,ix))*10000,'filled','ButtonDownFcn',@click)
view(app.UIAxes, [0 90]);
c = colorbar(app.UIAxes)
colormap(app.UIAxes, jet)
axis(app.UIAxes, 'tight')
axis(app.UIAxes, 'equal')
app.EditField.Value=value;
function click(~,eventData)
coords = eventData.IntersectionPoint;
app.ZEditField.Value=coords;
end
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by