Clear Filters
Clear Filters

How to expand the time width of small part of a signal with the total time width of the signal be same?

9 views (last 30 days)
Here I have the signal as shown above, but I need to expand the time width of the signal in the portions that is marked in red colour i.e, the width of the given portion marked in red colour is 10 (15 to 25, as shown in fig.), but I need to increase the width by 20. However, the total width of the signal should not be changed i.e, 40.

Answers (1)

Tushar on 14 Sep 2023
Hi Bipin,
I understand that you want to expand the x-axis scale between 15 and 25, while keeping the scale unchanged for the rest of the values.
Unfortunately, it is not possible to do so in the same x-axis. However, as a possible workaround, we can have a subplot over the same plot. It will put emphasis on the section you want to highlight. Here’s an example to place a zoomed in version as a subplot:
% Create the x and y values
x = linspace(0, 40, 100);
y = sin(x/2);
figure; % Create a figure
% Create the main axes for the complete data
plot(x, y, 'blue');
xlim([0, 40]);
% Create a secondary axes for the zoomed-in region
secondary_axes = axes('Position', [0.45, 0.6, 0.4, 0.25]); % Adjust the position as needed
plot(x, y,'red');
xlim(secondary_axes, [15, 25]);
Hope this helps you to emphasize a certain region of a plot,
Tushar Agarwal

Community Treasure Hunt

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

Start Hunting!