matlab边算边出图命令,Matlab:不包含边境和工具栏的figure(移除保存图片的白边)...
Matlab:不包含邊界和工具欄的figure(移除保存圖片的白邊)
當我們使用matlab的imshow命令顯示圖片時,會有白框和工具欄出現。在保存圖片時會出現白色的邊框。下面將說明如何去除這些顯示。
Matlab啟動時運行腳本'script.m',文件位置在~/matlab/ directory。在該文件加上一行,或者在顯示figure時加命令
>>iptsetpref('ImshowBorder','tight');
圖片即可顯示,并且保存時沒有白框。此方法僅僅適用'imshow'命令,不適用'imagesc'命令。
如果在'startup.m'文件中包含以下命令:
%在所有的figure去除菜單欄和工具欄
>>set(0,'DefaultFigureMenu','none');
%'disp'命令顯示無空行
>>format compact;
這三條命令可以去除matlab默認的很多沒有意義的顯示信息。
翻譯原文:http://www.shawnlankton.com/2007/06/matlab-figures-without-borders-and-toolbars/comment-page-1/#comment-2101
Something that has bothered me for *the entire* time I’ve used it is that when you show images using ‘imshow’ the resulting figure has the image surrounded in a sea of gray border. Well, I hate that gray border. It serves no purpose and today I have figured
out how to remove it!
Matlab runs a script called ‘startup.m’ when it starts. This is located in your ~/matlab/ directory. If you include this line into that file (or just type it before you make the figure) then you remove the gray border:
>>iptsetpref('ImshowBorder','tight');
Its glorious… Now the picture scales to fill the whole window! (note this only works with the ‘imshow’ command, not ‘imagesc’).
BUT! That’s not all. I also learned about some other cute little tricks that should be included in your startup.m (if you’re me at least).
%removes menu and toolbar from all new figures
>>set(0,'DefaultFigureMenu','none');
%makes disp() calls show things without empty lines
>>format compact;
I feel like these three commands cut a lot of the pointless (inefficient) crap out of Matlab’s default display interface. Thanks to commenter?Matt?who
pointed me toward the set(0,’Default… thing. You can use this to set up *tons* of settings so that you don’t have to set it every time. Just call:
>>set(0,'Default');
For some other useful tips on exporting figures for papers, check?this related
post.
總結
以上是生活随笔為你收集整理的matlab边算边出图命令,Matlab:不包含边境和工具栏的figure(移除保存图片的白边)...的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 拆开电脑后让人哭笑不得拆开电脑后让人哭笑
 - 下一篇: 电脑反应慢怎么办电脑开机慢的解决办法