Looking to use region-zoom interaction following the ginput selection

6 ビュー (過去 30 日間)
Sayyam Kathuria
Sayyam Kathuria 2022 年 8 月 24 日
回答済み: Neha 2023 年 8 月 31 日
Hi,
I wanted to know whether there was a way to use the region-zoom interaction following an initial ginput selection on the graph.
I am currently using a 1000 ms (1s) on the x-axis of my graph to pick the region of interest using ginput. After having clicked a point, I want the graph to zoom in to a 50ms window (25ms on each side of my initial point). It is in this 50ms window of higher resolution I wish to make a final marking that would then output in my dataset. Any soloutions?

回答 (1 件)

Neha
Neha 2023 年 8 月 31 日
Hi Sayyam,
I understand that you want to zoom in to a specific region of interest after using "ginput" to select a point on the graph. You can refer to the following code snippet:
x = linspace(0, 1000, 1000); % x-axis values (1000 ms)
y = sin(2*pi*0.01*x); % y-axis values
plot(x, y)
xlabel('Time (ms)')
ylabel('Amplitude')
title('Zoom-in Example')
% Use ginput to select a point on the graph
[x_selected, ~] = ginput(1);
% Define the zoom window size
zoom_window = 50; % 50 ms
% Calculate the x-axis limits for the zoomed region
x_zoom_start = x_selected - zoom_window/2;
x_zoom_end = x_selected + zoom_window/2;
% Set the x-axis limits for the zoomed region
xlim([x_zoom_start, x_zoom_end])
% Prompt the user to make a final marking in the zoomed region
[x_final, ~] = ginput(1);
fprintf('Final marking: %.2f ms\n', x_final);
Hope this helps!

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by