Clear Filters
Clear Filters

How to dynamically update Signal Editor using system outputs

4 views (last 30 days)
I'm hoping to configure a test harness using Signal Editor where there is closed-loop feedback from the outputs of my system to the input signal. The input signal is provided by a .mat file which is processed by a Signal Editor block.
How could I rewrite the input to my system as a function of the previous timestep output using Signal Editor? Does Signal Editor re-process the .mat file signal for every single timestep, or is the signal fully developed before the simulation occurs?
In other words, is there a way to append new signal input values (as a function of previous timestep output) to the .mat file to feed into my system through Signal Editor? Is there any other way to do this?

Answers (1)

Abhijeet
Abhijeet on 7 Mar 2023
Hi Aarish,
Yes, it is possible to append new signal input values to a .mat file and use the Signal Editor in MATLAB to feed them into your system.
Here is an example:
% Open the existing .mat file
m = matfile('mydata.mat','Writable',true);
% Get the last output value from the file
last_output = m.output(end);
% Calculate the new input value based on the last output value
new_input = my_function(last_output);
% Append the new input value to the input signal in the file
m.input(end+1) = new_input;
The code gets the last output value from the file, calculates the new input value based on the last output value, and then appends the new input value to the end of the input signal in the file using m.input(end+1) = new_input.
Once you have appended the new input value to the .mat file, you can use the Signal Editor in MATLAB to edit the input signal and feed it into your system.
Thank You

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!