Clear Filters
Clear Filters

Unable to resolve the name 'out.EM_n'

12 views (last 30 days)
DAVIDE PARMIGGIANI
DAVIDE PARMIGGIANI on 3 Jun 2024
Answered: Ayush Singh on 11 Jun 2024
Hi, I've a MATLAB/Simulink program that is launched by the GUI. Actually, I can't plot some parameters through the Stopfcn, because if i launch the program with GUI they're not saved in the workspace, so I'm forced to run the simulation by Simulink.
---- Error evaluating 'StopFcn' callback of block_diagram '****'
scatter(out.EM_n,out.EM_T,'filled','.','markeredgecolor',[1 0 0])
Unable to resolve the name 'out.EM_n' ----
'Save data to workspace or file' is set to 'Single simulation output'

Answers (1)

Ayush Singh
Ayush Singh on 11 Jun 2024
Hi Davide,
By default 'Save data to workspace or file' is set to 'Single simulation output', so Simulink saves all the simulation outputs in a single 'Simulink.SimulationOutput' object. To access the data, you need to refer to the specific signals you're interested in by their names as fields of this object.
Below are possible steps you can try out to resolve the issue:
  1. First, ensure that the signals EM_n and EM_T are being logged. You can log signals by right-clicking on a signal in your Simulink model and selecting 'Log Selected Signals'. This action marks the signal for logging, and its data will be available in the simulation output.
  2. Assuming 'out' is the variable you have your simulation output saved to, you access logged signals like this:
EM_n_data = out.logsout.get('EM_n').Values;
EM_T_data = out.logsout.get('EM_T').Values;
3. Now you can use the 'scatter' function like below:
scatter(EM_n_data,EM_T_data,'filled','.','markeredgecolor',[1 0 0])
Hope it helps!

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!