Borrar filtros
Borrar filtros

plot function in predesigned figure

3 visualizaciones (últimos 30 días)
Josefina Ottitsch
Josefina Ottitsch el 23 de Feb. de 2019
Comentada: Josefina Ottitsch el 23 de Feb. de 2019
Hello!
tryscript is my script, tryyy is my desired function and f_vorlage is where I define h. h is the in f_vorlage predesigned graph I want to put my function x in.
But, it doesnt work. As soon as tryyy plots x it sort of deletes h?
I want to plot x in my predesigned h.
How do I do this?
Thank you for the support!

Respuesta aceptada

Asad Mirza
Asad Mirza el 23 de Feb. de 2019
Editada: Asad Mirza el 23 de Feb. de 2019
Perhaps use hold on?
h=figure(1);
hold on
f_vorlage(h)
tryyy(h)
In addition in your tryyy.m have it grab the current plot handle with gca
function tryyy(fig)
h=gca
ax = findobj(h, 'type', 'axes');
if isempty(ax)
error('Your figure does not have any existing axes')
end
if length(ax) > 1
error('Your figure has more than one axes')
end
x=[52.23;52.45;56.32;55.48;56.32;53.39;55.53;53.67;57.89]
x=x'
plot(x)
untitled.jpg
Using a random set of values it looks like it plots properly
function tryyy(fig)
h=gca
ax = findobj(h, 'type', 'axes');
if isempty(ax)
error('Your figure does not have any existing axes')
end
if length(ax) > 1
error('Your figure has more than one axes')
end
x=200*rand(1,10000)-50;
plot(x)
untitled2.jpg
  3 comentarios
Asad Mirza
Asad Mirza el 23 de Feb. de 2019
It should work but I suspect that because your y scale stops at 200 you cannot see the rest of the graph.
axis auto
Should fix your scaling issue but you'd have to figure out a way to fix your nice grid to change depending on the largest data point you're plotting.
Josefina Ottitsch
Josefina Ottitsch el 23 de Feb. de 2019
yes this is the solution! thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by