Wednesday, February 4, 2009

在MATLAB/Simulink环境中编辑Scope中的图形方法

问: Matlab仿真中怎样编辑Scope中的图象???

答: 实现的方法有以下的几种:

1)PrintScreen,然后粘贴到Windows位图编辑器,选择图像点击右键,选择“反色”即可;

2)在Scope中,它的参数设置的第二页,有一个Save Data to Workplace,将它选中,然后在下面的方框中指定变量名,然后用plot命令画出;

3)直接在模型上再加一个,to Workplace模块,也用plot画出;

4)直接在模型上加一个,outport模块,用plot命令绘制tout和yout;

5) 等scope显示出来图像以后,在matlab的命令行窗口中运行: set(0,'ShowHiddenHandles','On'); set(gcf,'menubar','figure'); 这时候你会发现scope的工具栏的上面多了一行,与plot命令得到的figure的工具栏是一样的。点击insert-axes,鼠标会变成十字形状,然后再图像的任意一处双击左键出现一个对话框PropertyEditor,选中style在窗口的右便会出现color,这时你就可以任意修改背景颜色了。

Question: How to edit the Scope's figure in the MATLAB/Simulink?

Answer: There are several methods to edit Scope's figure in the MATLAB/Simulink environment.

1). Print Screen. Print screen maybe the most convinent method to edit Scope's figure. Whe finished the simulation, The Scope block will display the simulation result. Press the keyboard key Print Screen(In PC, correspond to the key Print Screen, in notebook, maybe "prt sc" and so on), and paste to the windows bitmap editor(Start->program->attachment->draw), select the print figure, and press right button, "reverse color" menu is selected.

2). In the Scope, press the property setting button, and in the second properties page, select "Save Data to Workplace", and at the same time, fill the variable name in the following box, and after simulation, the variable will exist in the currt workspace. Then go to the MATLAB command workspace, PLOT the saved variables.

3). Add a "To Workspace" block in the simulation model. Operation is same as the second (2) method. After simulation, the variables will exist in the MATLAB command workspace. PLOT command could be used.

4). Add a "Outport" block in the simulation model. Operation is same as 2) and 3). PLOT command is available to plot the new variables tout and yout.

5). When simulation is finished, turn to the MATLAB command workspace, and type the following commands:
set(0,'ShowHiddenHandles','On');
set(gcf,'menubar','figure');
After the commands are executed, A new toolbar will appear in the Scope block which is just same as the figure toolbar with PLOT command. You can use the toolbar to set the figure properties.
More details could be found in my published book:
MATLAB编程基础与典型应用
北京:人民邮电出版社,2008
ISBN:978-7-115-17932-6/TP

Pls contact me with Email:lhd06@mails.tsinghua.edu.cn