How to dynamically update Signal Editor using system outputs
6 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Abhijeet
2023-3-7
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!