I have a GUI which gets input from user and plots the step response. I want to export that graph only, not whole figure window. Can you help how to do?

This is the figure saved from that GUI. As you can see that it has captured the whole figure window layout, however I want to save only the plot in the figure as an image on my computer.

回答 (1 件)

awezmm
awezmm 2018 年 11 月 2 日
Can you just make a new figure window and put only the plot on that one and then export that new figure? Note that you can make the new figure invisible if you don't want the user to see it: f = figure('visible','off'); It will still be running in the background and you can programmatically export the stuff on the new figure f that only contains your plot

6 件のコメント

GMD Baloch
GMD Baloch 2018 年 11 月 3 日
編集済み: GMD Baloch 2018 年 11 月 3 日
Thanks awezmm,I have used this technique but it produces the following figure in which the graph is not stretched along whole figure i.e. it appears smaller. I am using the following code for this can you please help
ax = figure()
copyobj(handles.axes1,ax);
awezmm
awezmm 2018 年 11 月 3 日
How are you originally plotting the graph on axes1? Is it the same size as it was before
Because if you just copy from one figure to another it will retain the size. Instead it may be best to plot it onto the new ax figure instead of copying it over
I am first generating a transfer function using tf command and then plotting the step response using step command. The code for this is
n = str2double(get(handles.num,'String'));
d = str2double(get(handles.num,'String'));
s = tf(n,d);
step(s)
awezmm
awezmm 2018 年 11 月 5 日
did u try plotting straight on the new figure ax
You are right but my problem is that I will have a different plot every time because a drop down menu and depending on the user's choice my plot would change. Isn't there any way to extend the figure's contents upto the whole figure window?
try putting this before you plot:
axes('Units', 'normalized', 'Position', [0 0 1 1])
again, plot on everything separately, try not to use copy.
Here is an example of the command I gave: This is normal plotting:
figure
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
This is where the plot fills everything:
figure
x = 0:pi/100:2*pi;
y = sin(x);
axes('Units', 'normalized', 'Position', [0 0 1 1])
plot(x,y)
lemme know if you have any other trouble

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索

製品

質問済み:

2018 年 11 月 2 日

コメント済み:

2018 年 11 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by