05 - Accessing Trace Data from the MATLAB Variable
This chapter explains about the generated variable, how to extract data from the generated variable, and how to use the data in MATLAB to generate various plots. Following topics are covered in this chapter:
- What is the generated MATLAB variable?
- How to check if the MATLAB variable is generated or not?
- How to launch the desktop version of MATLAB from the MATLAB command window?
- How to access the trace data from the MATLAB variable using customized MATLAB scripts?
- How to access the previously generated MATLAB variable in the current session of MATLAB workspace?
- Where are various customized scripts stored in the Cadence hierarchy and how to use them?
What is the generated MATLAB variable?
Whenever you export the traces to MATLAB, either a default MATLAB variable is generated in the MATLAB Command Window, such as PSpiceData_N, where N is a digit; or a customized MATLAB variable is generated in the MATLAB Command Window, such as MyVAR.
The MATLAB variable is a structured array that contains the following:
- full path of the trace data file (.dat)
- name of the trace data file
- trace data in the Analysis struct variable
The following diagram illustrates the tree structure of the generated MATLAB variable:
How to check if the MATLAB variable is generated or not?
To check if the MATLAB variable is generated in the MATLAB command window, type who on the command prompt of the MATLAB Command Window.
Once done, you will see the name of the variable getting displayed if it is generated. The following screen shot shows that two variables, MyVAR and PSpiceData_1, are present in the current MATLAB Command Window session:
How to launch the desktop version of MATLAB from the MATLAB command window?
Type desktop in the MATLAB Command Window’s prompt to launch MATLAB’s desktop version.
How to access the trace data from the MATLAB variable using customized MATLAB scripts?
As the trace data is saved as a structured array in the MATLAB variable, you can access the trace data using the customized scripts shipped with the Cadence hierarchy or using various MATLAB commands.
How to access the previously generated MATLAB variable in the current session of MATLAB workspace?
You can not access previously generated MATLAB variables in the current session of the MATLAB workspace unless you have saved the previous MATLAB workspace session. As MATLAB workspace sessions are independent of each other, therefore all the trace data is lost after you close them.
If you want to access the currently generated MATLAB variable again, you need to save the workspace as .mat file. To save a MATLAB current workspace as .mat file, click Save Workspace in the Home tab. Once you save the workspace, you can re- use the generated MATLAB variable in the new MATLAB workspace session by opening the saved the .mat file.
Where are various customized scripts stored in the Cadence hierarchy and how to use them?
To access the customized MATLAB scripts from the Cadence hierarchy, browse the following location in the MATLAB’s current folder window: < installation_directory>\tools\pspice\tclscripts\orPSPMatlab\MatlabScripts
Following MATLAB scripts can be used to access the trace data stored in the generated MATLAB variable:
- getPspiceData
- getPrimaryParamData
- getPrimaryParamName
- getSecondaryParamData
- getSecondaryParamName
- listPSpiceDataStructAccess
- listPSpiceDataStructAccessAll
- plotTraces
getPspiceData
Use this customized MATLAB script to get the trace data of the MATLAB variable.
Syntax
Parameter Description
varName – Name of variable created in MATLAB
traceName – Trace name to be used with single quotation marks
analysisName – Analysis name to be used with single quotation marks
getPrimaryParamData
Use this customized MATLAB script to get the trace data of the MATLAB variable’s primary parameter.
Syntax
Parameter Description
varName – Name of variable created in current session of the MATLAB Command Window
analysisName – Analysis name to be used with single quotation marks
getPrimaryParamName
Use this customized MATLAB script to get the name of the MATLAB variable’s primary parameter.
Syntax
Parameter Description
varName – Name of variable created in current session of the MATLAB Command Window
analysisName – Analysis name to be used with single quotation marks
getSecondaryParamData
Use this customized MATLAB script to get the trace data of the MATLAB variable’s secondary parameter.
Syntax
Parameter Description
varName – Name of variable created in current session of the MATLAB Command Window
analysisName – Analysis name to be used with single quotation marks
getSecondaryParamName
Use this customized MATLAB script to get the name of the MATLAB variable’s secondary parameter.
Syntax
Parameter Description
varName – Name of variable created in current session of the MATLAB Command Window
analysisName – Analysis name to be used with single quotation marks
listPSpiceDataStructAccess
Use this customized MATLAB script to list a specific trace information in a log file. The generated log file will be saved at the same location as the .dat file.
Syntax
Parameter Description
varName – Name of variable created in current session of the MATLAB Command Window
matlanVarName – Same as varName and to be used with single quotation marks
traceName – Trace name to be used with single quotation marks
listPSpiceDataStructAccessAll
Use this customized MATLAB script to list information of all traces in a log file (.log). The generated log file will be at the same location as the .dat file.
Syntax
Parameter Description
varName – Name of variable created in current session of the MATLAB Command Window
matlanVarName – Same as varName and to be used with single quotation marks
plotTraces
Use this customized MATLAB script to plot selected traces.
Syntax
Parameter Description
varName – Name of variable created in current session of the MATLAB Command Window
analysisName – Same as varName and to be used with single quotation marks
traceList – Space separated list of traces to be used with single quotation marks
View the next document: 06 - Introducing PSpice Simulink Co-Simulation
If you have any questions or comments about the OrCAD X platform, click on the link below.
Contact Us