Hi,
I want to plot arrival pulsed signals in a time sequence similar to the attached figure.
Basically, I have to flip the signals 90 degree and number each signal corresponding to its offset. I think it is going to be a multi y-axis plot. How to plot multiple graphs with multiple y-axes which share the same x-axis?
Thank you

 Respuesta aceptada

Star Strider
Star Strider el 25 de Jul. de 2018
Plot ias you normally would, using the fill function, then rotate it using the view function:
offset = 1:2:20; % Create Data
time = linspace(0, 1, 250); % Create Data
frq = 1:10; % Create Data
signal = bsxfun(@plus, sin(frq(:)*time*3*pi), offset(:)); % Create Data
figure
fill(time, signal, 'g')
view(90, 90)
xlabel('Time (s)')
ylabel('Offset (km)')
Experiment to get the result you want.

2 comentarios

Sitthichat Sukpholtham
Sitthichat Sukpholtham el 26 de Jul. de 2018
This looks nice! However, what does the function bsxfun actually do? I understand that it is used to stack up all plots together
Star Strider
Star Strider el 26 de Jul. de 2018
Thank you!
The bsxfun function performs the desired operation specified in the first argument by expanding the single dimension the two arguments share (here 10) and then doing the operation (here, addition). I think of ‘bsx’ as standing for ‘binary singleton expansion’.
The alternative is to use a for loop to perform the addition, or using the repmat function to create a matrix of ‘offset’ values equivalent to the size of the original signal matrix (created here by the sin call), and then adding. The bsxfun function is significantly faster and more efficient than either of these, even for small problems.
In my code, bsxfun adds the ‘offset’ vector to the matrix created by the sin call ‘sin(frq(:)*time*3*pi)’ to separate the rows by increments of 2 to keep them from overlapping. You can choose larger (and non-integer) increments for ‘offset’ if you want, so long as the length of the vector is the same as the row size (dimension 1) of your original matrix of signals (in my code, created by the sin call, in your code, your data matrix of signals).
Without the bsxfun call, the signals would plot on top of each other, all centred at y=0 rather than separated vertically (or after the view call, horizontally).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Measurements and Spatial Audio en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 25 de Jul. de 2018

Comentada:

el 26 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by