Hi,
In the upper part of attached/copied figure, the encircled area, the graph has values equal to one (straight/flate line). Suppose I want add some fluctuation in the flat line such that numerical values remain in between 0.96 -0.99.
Is there any way I can do in Matlab? Please guide me in this regard.

 Respuesta aceptada

Jon
Jon el 4 de Nov. de 2021
Editada: Jon el 4 de Nov. de 2021
I think you can adapt the approach that I illustrate here:
% generate original function with flat zone
t = linspace(1970,1880);
x = zeros(size(t));
% use logical indexing to work on specific portions of curve
x(t<1918) = 1;
x(t>1918) = 0.5+0.1*randn(size(x(t>1918)));
% plot original curve
figure,plot(x,t)
% make the early years noisy too
sigma = 0.015;
xbar = (0.96+0.99)/2;
x(t<1918) = xbar + sigma*randn(size(x(t<1918)));
figure,plot(x,t)
My y axis (years?) is increasing rather than decreasing like yours. This is the normal way to make an x-y plot. I'm not sure if this is important to you. I mostly just wanted to illustrate how you add the noise to a selected portion of your graph.

3 comentarios

Jon
Jon el 4 de Nov. de 2021
Editada: Jon el 4 de Nov. de 2021
If you want to plot with the early years at the top of the graph set the axis directionafter you make the plot like this
figure,plot(x,t)
set(gca,'Ydir','reverse')
Nisar Ahmed
Nisar Ahmed el 8 de Nov. de 2021
Thank you @Jon, it is working
Jon
Jon el 8 de Nov. de 2021
Glad to hear. Good luck with your project

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 4 de Nov. de 2021

Comentada:

Jon
el 8 de Nov. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by