Borrar filtros
Borrar filtros

plot in different ranges for x

10 visualizaciones (últimos 30 días)
Muhammad Usman
Muhammad Usman el 25 de Nov. de 2014
Respondida: solov andrei el 15 de Mayo de 2015
i want to plot a function say sin(x) for the interval 0:30 and then i want to continue this plot for some other function say ax+b (a,b are constants) for the interval 30:40,how can a manage this plot and also x-axis. Thanks

Respuesta aceptada

Image Analyst
Image Analyst el 25 de Nov. de 2014
Here's one way. Just make up each and stitch together:
x1 = linspace(0, 30, 100);
y1 = sin(x1);
x2 = linspace(30, 40, 30);
a = .15;
b = -5;
y2 = a*x2 + b;
x = [x1, x2];
y = [y1, y2];
plot(x, y, 'bo-');
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
  4 comentarios
Image Analyst
Image Analyst el 25 de Nov. de 2014
Editada: Image Analyst el 25 de Nov. de 2014
You're welcome. Thanks for accepting. If the ranges of the two y's are very much different , then you can also use plotyy() which will give each curve it's own independent Y axis (one on each side of the graph).
Muhammad Usman
Muhammad Usman el 26 de Nov. de 2014
yes i got help about plotyy() in documentation but you solved my issue

Iniciar sesión para comentar.

Más respuestas (1)

solov andrei
solov andrei el 15 de Mayo de 2015
thanks

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by