Is there a way to access user defined variables in vsfi file? - matlab

Summary: Is there a way to access user defined variables in vsfi file?
After my simulation is done, in a vsif file, I kick off a post simulation script that will launch Matlab to analyze the output of the DUT.
In order to analyze the data in Matlab I need to compare expected values with observed values. Some of these expected values are defined in my test.e. Is there a way to pass a simulation run variable ( in test.e) to my vsif file?
Thank you

I don't think what you want is possible, as Specman and Vmanager are different tools. Since you're going the post-processing way, you can just dump a text file from your e code that your Matlab script can read.

The .vsif file is descriptive and read at the beginning of the session, so you can't pass information from a task to another task.
I would suggest the same as Tudor.

Related

Read value from Excel into parameter. Parameters are linked to delay block. Error Excel file can not be resolved

I am trying to read values from excel file into different parameters created as flow chart block. Error excelFile cannot be resolved. Steps I have done to import excel:
1- created new experiment.
2- From pallet connectivity imported excel file saved in the same file as model.
3- In experiment window, opened Java action, before each experiment window typed the following code "excelFile.readFile();"
4- into parameter block, Action, on enter delay, typed the following "excelFile.getCellNumericValue("sheet1",5)"
Please see picture for more info
Your "excelFile" object lives on the "Simulation" object, your process blocks are on "Main".
Please learn about object-oriented structures and read the AL help on understanding this: "Where am I and how do I get to..."
In your case, best move the ExcelFile object to Main and access it from there, probably no reason to have it on "Simulation", right?
Also, consider not using ExcelFile at all. Instead, read your excel data into the build-in database and load your params from there. This is how it should be done ;)

How to retrieve VSTS Build variables?

Is it possible to get the values for custom variables being used in the build? I know they can be dumped to the console output as per what this example describe. But still want to find an easier way to archive it.
http://www.codewrecks.com/blog/index.php/2017/08/04/dump-all-environment-variables-during-a-tfs-vsts-build/
There isn’t the easier way then the way you provided to retrieve build variables, the value of variable can be changed during the build time (Logging Command), so it’s better to retrieve the variable at the end of the build (the way you provided).
Note, the secret variables can’t be output as general text.

Run Simulink from Matlab function

I am running Simulink using FastRestart, as I need to start and stop the simulation multiple times changing parameters. When I run Simulink from the main script, there are no problems. However, as soon as I make the script a function so that I can run it for different input data, I get an error that is clearly related to Simulink not seeing the Matlab workspace within the function.
To be more precise, say sfile is my Simulink file, then I run the following lines AFTER having initialized all variables I need in structures in Matlab:
load_system(sfile);
set_param(sfile,'FastRestart','on');
set_param(sfile,'SaveFinalState','on');
set_param(sfile,'SaveCompleteFinalSimState','on');
set_param(sfile,'SimulationCommand','update');
At the last line, I get the error that Simulink does not recognize mdl.tStep (which is the time step), as mdl is not a recognized structure. In fact, it is and if I run Simulink from the main script everything is fine.
Now, in the past, I would have used
options = simset('SrcWorkspace','current');
However, an expert I know has advised me against simset (as it may get deprecated in the future) and encouraged me to use set_param instead. I have
looked up the options for set_param on-line, but I could not find the setting for the Matlab workspace.
Any help would be greatly appreciated. Thank you in advance!
In many instances it is better to use the Model Workspace rather than the Base Workspace:
hws = get_param(model, 'modelworkspace');
hws.assignin('mdl',mdl);
At least be aware that this option exists.
A solution to your problem might be to use the assignin-function to all the variable whose value you want to pass to simulink in your matlab base workspace. To do so just use
assignin('base','mdl',mdl)
Having the variable in your base workspace should allow simulink to see it.

Get parameter values from .m-file into GUI

To keep it short, I'm developing a software tool where I would like to import
parameters into GUI from .m-files, but I can't find how to import the parameters.
I'm using iugetfile to 'reach it' but how do I insert the parameter values?
If I open the file in MATLAB (command window), then I get the parameters in
the workspace. Is there an easy way to read the parameters into GUI to be able
to use them in functions there?
The way to write data into gui is using set. For example: set(handles.,'String','content'). You can see examples of writing and reading values from here: (mathworks link)
I would use .mat instead .m if you need to read parameter values.

Pass variable from GUI to function in MATLAB

I have a MATLAB GUI that loads to aid in visually pre-processing data. Essentially it prompts the user to adjust the data range, reduce number of data points, etc... all while providing an updated graph. Upon completion of this work, I want to be able to close out the GUI and pass variables from the GUI to another MATLAB function that does the data analysis. I have found lots of information on how to pass information from a function TO and GUI, but not the other way around.
Any help would be greatly appreciated.
Global variables can cause hard to find bugs. The best solution for your problem (where you want to pass the data directly to another function on close) might be to call the analysis function from the Figure Close Request Function. When the figure your GUI is running in is told to close, it will run the code in this function, which can call your analysis function and have access to the GUI's data.
Matlab GUIs are functions: the code exists in a .m file just like other functions. Like regular functions, they can have return values. You can get as fancy as you want messing with the varargout system, or you can simply return a value, structure, or cell array containing whatever you want. Open up the m-file and edit it to return what you want it to.
Note: If you require special processing when the figure is being closed to generate the appropriate return value, you can reimplement the closeRequestFcn as you see fit.
The easy way: you declare as global variable, where variable stores the data that you want to carry from the GUI to the main MATLAB workspace. Then, you also declare the same global variable on the command window. Hereinafter, variable to be accesible from both scopes, the GUI and the main workspace.
You could also use save or any other alternatives as csvwrite or dlmwrite to store the data into a file, but this doesn't seem to be your case.