How to modify model input values based on conditions during testing in Simulink Test?

30 views (last 30 days)
I have created a test framework with Inport and Outport for the model. I use Excel spreadsheets to create the model inputs. There is an input interface in the model for setting SOC, and I hope to modify the SOC setting value during the test based on certain simulation conditions. Is this functionality achievable? Currently, I can add a Matlab Function within the test framework to achieve this, but this would change my test framework. Are there any other ways to accomplish this?

Accepted Answer

Samhitha
Samhitha on 27 Jan 2026 at 9:24
Hi @Ke,
This is possible by using a Test Sequence block in the test harness. The Test Sequence block allows you to change the SOC value during the simulation when specific conditions are met. This can be done without modifying the model or the test framework itself.
All the logic for changing SOC stays inside the test harness, so your model remains clean and unchanged. This makes the solution simple and easy to maintain, while still giving you full control over how and when the SOC value is updated during the test.
For more information you can look into the following documentation:
Thank you!
  2 Comments
Ke
Ke on 27 Jan 2026 at 13:27
Hello, thank you for your response. Using the Test Sequence harness, I can modify the values of my SOC settings, but the Test Sequence harness cannot import external data.
Samhitha
Samhitha on 29 Jan 2026 at 2:50
Hi @Ke,
Since the Test Sequence harness can’t directly work with external files like Excel, a simpler approach is to use External Input control instead. You can load the SOC data from Excel into MATLAB as a timeseries, apply your logic to modify that SOC signal before the simulation starts, and then feed it into the model using External Inputs. This way, the SOC still changes based on your conditions, but you don’t need the Test Sequence to handle external data, and you don’t have to change the model or the test framework. All the logic stays in the test layer.

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!