How to find name of test result object?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi there! I've been trying to create a figure using custom criteria in Test Manager, but I'm having trouble finding the right data object to use in my code. In the document 'Create, Store, and Open MATLAB Figures - MATLAB & Simulink (mathworks.com)' there's an example code snippet that uses the variable 'sldemo_absbrake_output',
% Log data object and store in sldemo_absbrake_output variable
out = test.sltest_simout.get('sldemo_absbrake_output');
% Plot wheel speed and car speed
subplot(3,1,1);
plot(out.get('yout').Values.Vs.Time, ...
out.get('yout').Values.Vs.Data);
but I'm not sure what my own data object is named or how to modify it. I've tried several combinations of file names and test names, but nothing seems to work. Can you please help me figure out how to identify and use the correct data object in my code?
0 comentarios
Respuestas (1)
Aishwarya Shukla
el 29 de Mzo. de 2023
To identify the correct data object to use in your code, you need to know the name of the output signal you are interested in plotting. This signal name should be defined in your Test Manager test case.
Assuming you have already run the test case and generated simulation data, you can access the output data object using the sltestlogs object in MATLAB. Here's an example code snippet that shows how to access the data object for a signal named 'mySignal':
% Get the Test Manager test run results
logs = sltestlogs;
% Get the signal data object for 'mySignal'
out = logs.getElement('TestRun').getSignal('mySignal');
In this example, the logs object represents the entire set of test logs generated by Test Manager. We first use the getElement method to get the test run results for the most recent test run. We then use the getSignal method to get the data object for the signal named 'mySignal'.
Once you have the data object, you can plot the signal data using the plot function, similar to the example you mentioned. Here's an example code snippet that shows how to plot the signal data:
% Plot the signal data
figure;
plot(out.Values.Time, out.Values.Data);
xlabel('Time (s)');
ylabel('Signal Value');
title('My Signal');
In this example, we use the Values property of the data object to get the time and signal data. We then plot the signal data using the plot function, and add labels and a title to the plot.
I hope this helps! Let me know if you have any further questions.
0 comentarios
Ver también
Categorías
Más información sobre Outputs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!