フィルターのクリア

plot function in predesigned figure

2 ビュー (過去 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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by