Looking to use region-zoom interaction following the ginput selection

1 view (last 30 days)
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?

Answers (1)

Neha
Neha on 31 Aug 2023
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!

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!