Hi All,
I want to expand a waveform on the x-axis. Specificlly, in the following fig, I would like to expand a waveform in such a way that the waveform from with X = 0:1 sec is expanded from x = 0:2.5. In other words, I would like to plot the waveform such that the duration from 0 to 1 sec be plotted as five big boxes, i.e., each grided box. Any suggestions would be appreciated.

2 comentarios

Walter Roberson
Walter Roberson el 26 de Ag. de 2022
Are you asking for something like an inset "picture in picture" zoomed view in addition to what you have now?
Are you asking for the axes to be non-linear, with 0 to 1 taking roughly the first half of the plot, and 1 to 5 taking roughly the second half of the plot?
Susan
Susan el 26 de Ag. de 2022
Editada: Susan el 26 de Ag. de 2022
@Walter Roberson Thanks for your response, and sorry if the question was not straightforward. I want to be able to plot the figure with having control over the griding space. In the above Fig, I like to have 25 small boxes from 0:1. In other words, I want to say that 25 small boxes are equal to 1 second and be able to to specify the spacing between grid lines, if it makes sense.

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de Ag. de 2022

0 votos

MATLAB only gives control over major ticks, with it deciding minor ticks automatically. Grid lines are drawn at the minor tick positions.
So if you want grid lines at specific distance, you can set those positions as major ticks in xticks. Or you can draw the lines yourself.
Your current range is 0 to 5, so 0 to 1 is 1/5 of the space. You want 25 boxes in that space so each will take 1/25 of 1/5 = 1/125 of the width. If your axes is 750 pixels wide that would make the boxes 6 pixels apart. I don't think I see the benefit of drawing boxes that fine.

3 comentarios

Susan
Susan el 26 de Ag. de 2022
Editada: Susan el 26 de Ag. de 2022
Thanks for your response, Walter. Could you please tell how can I do that using the xticks (.fig file is attached)? The goal is to set the y-axis unit as mm/mV and the x-axis unit as mm/sec, assuming each small box can be considered 1 mm. Knowing that it may result on very tiny boxes with narrow width, is there a way we can controler the boxes' width by adjusting the # of pixels?
xt = [0:1/25:1, 1.5:.5:5];
xticks(xt);
labs = string(xt);
labs(1:26) = "";
labs([1:5:26]) = string(0:0.2:1);
xticklabels(labs)
Susan
Susan el 27 de Ag. de 2022
@Walter Roberson Thank you so much for your help. It works perfectly!

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 26 de Ag. de 2022

Comentada:

el 27 de Ag. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by