이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
how to know the dimension of a figure window and then draw my own according to same dimension
조회 수: 8 (최근 30일)
이전 댓글 표시
If I have a figure window which is open. How can I know its dimesnion? I mean how can I know its size (length and width)? Once I know the dimesnion of the open figure window, then I want to draw my own figure window of the same dimension. How can we do that?
채택된 답변
Ameer Hamza
2020년 10월 14일
편집: Ameer Hamza
2020년 10월 14일
If it is already open and you don't have its handle, then first get it
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
pos is 4 element vector [x y w h]. x and y are the positions of the bottom left corner of the figure window in screen coordinates (by default in pixels). w and h are the width and height of the window (by default in pixels too). Create a new figure at the same position and with the same dimensions
fig2 = figure('Position', pos)
댓글 수: 16
Sadiq Akbar
2020년 10월 14일
Thank you very much Ameer Hamza for your prompt response. Yes it works. But if I have 8 figures already opened. And I have anothr 9th figure that is in current folder and is not opened.
Now if I want to make the dimesnions of the opened figures identical to the 9th figure, then how can we do that?
Ameer Hamza
2020년 10월 14일
You cannot do that without opening the figure. If you already know its dimensions, then you can hard-code these values manually, but there is no automatic way without opening the .fig file
fig2 = figure('Position', [10, 10, 500, 500])
Sadiq Akbar
2020년 10월 14일
Thank you very much for your 2nd prompt response. Ok I got it. If suppose I open the 9th figure also. And I find the dimension by the following command as you told me.
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
Now how can I insert this dimension in those 8 figures?
Sadiq Akbar
2020년 10월 14일
Thank you very much for 3rd response. No. I mean that I have opened all the 8 figures and then opened the 9th figure also. I will determine the dimension of the 9th figure according to the following command as you told me, i.e.
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
Now if the 9th figure is a reference for me and I want to make the dimension of all those 8 figures (already opened) identical to the 9th figure, and I don't have their handles, then how can we do that? Say for example their names are fig1, fig2,fig3,....fig8.
Ameer Hamza
2020년 10월 14일
Ok. Do something like this. Before opening the 9th figure, get the handle of the existing 8 figures
figs = findall(0, 'type', 'figure');
Then open 9th figure, get its handle and extract its position
fig = gcf(); % handle of current figure;
pos = fig.Position; % contains its position and dimensions
the run
[figs.Position] = deal(pos);
Sadiq Akbar
2020년 10월 14일
Thank you very much for your 4th reponse. Indeed I am very thankful to you for your precious time that you spare for my problem.
Can we make the above a single m file.i.e. If all the 8 figures are opened by my m file.Then if I open the 9th figure also and after that I run your m file and it makes all the 8 figures dimension equal to the dimension of the 9th figure?
Ameer Hamza
2020년 10월 15일
Ok. You can use the following function
function change_figures_size(fig9)
figs = findall(0, 'type', 'figure');
figs = setdiff(figs, fig9)
pos = fig9.Position;
[figs.Position] = deal(pos);
end
You can pass the handle of 9th figure to this function and it will handle the rest.
Sadiq Akbar
2020년 10월 15일
Thank you very much for your 5th response. I saved your program as a function. Then all the 8 figures were opened and then I opened the 9th figure also. After that I opened your program and clicked the run button.But it gives me the following error:
>> change_figures_size
Not enough input arguments.
Error in change_figures_size (line 3)
figs = setdiff(figs, fig9)
>>
Ameer Hamza
2020년 10월 15일
No, you cannot run it just like that. You need to pass the handle of 9th figure.
fig9 = openfig('9th_fig_file.fig');
change_figures_size(fig9)
Sadiq Akbar
2020년 10월 15일
Indeed it worked. Thank you very much for your tireless efforts and cosistant support and help. May you live long and help others like this. Thank you once again.
Ameer Hamza
2020년 10월 15일
You can post a new question and paste the link in the comment below. I will try to answer if possible.
Sadiq Akbar
2020년 10월 15일
Ok thank you very much dear Ameer Hamza for your kind support and devoted help. May you live long happily.
Sadiq Akbar
2020년 10월 15일
https://www.mathworks.com/matlabcentral/answers/615303-how-to-export-a-figure-into-ms-word
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)