'Plot the data in Matlab with some parameters calculated from the T_ANALYSIS
'structure. Set the axes labels, title, colorbar and plot view.
Matlab.Execute( "figure; surf(linspace("&xMin &","&xMax &","&nXpx &"),linspace("& yMin &"," & yMax & "," & nYpx & "),irradiance_pwd, 'EdgeColor', 'None');" )
Matlab.Execute( "xlabel('X Position (" & GetUnits() & ")')" ) : Matlab.Execute( "ylabel('Y Position (" & GetUnits() & ")')" ) : Matlab.Execute( "zLabel( 'Irradiance' )" )
Matlab.Execute( "title('Detector Irradiance')" )
Matlab.Execute( "colorbar" )
Matlab.Execute( "view(2)" )
Print ""
Print "Matlab figure plotted..."
'Have Matlab calculate and return the mean value.
Matlab.Execute( "irrad = mean(mean(irradiance_pwd));" )
Matlab.GetWorkspaceData( "irrad", "base", meanVal )
Print "The mean irradiance value calculated by Matlab is: " & meanVal
'Release resources
Set Matlab = Nothing
End Sub
最后在Matlab画图如下:
并在工作区保存了数据:
并返回平均值:
与FRED中计算的照度图对比:
例:
此例系统数据,可按照此数据建立模型
系统数据
光源数据:
Type: Laser Beam(Gaussian 00 mode)
Beam size: 5;
Grid size: 12;
Sample pts: 100;
相干光;
波长0.5876微米,
距离原点沿着Z轴负方向25mm。
对于执行代码,如果想保存图片,请在开始之前一定要执行如下代码:
enableservice('AutomationServer', true)
enableservice('AutomationServer')
|
|