필터 지우기
필터 지우기

plot function in predesigned figure

조회 수: 3 (최근 30일)
Josefina Ottitsch
Josefina Ottitsch 2019년 2월 23일
댓글: Josefina Ottitsch 2019년 2월 23일
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!

채택된 답변

Asad Mirza
Asad Mirza 2019년 2월 23일
편집: Asad Mirza 2019년 2월 23일
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
Asad Mirza
Asad Mirza 2019년 2월 23일
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 2019년 2월 23일
yes this is the solution! thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by