How to dynamically update Signal Editor using system outputs

6 ビュー (過去 30 日間)
Aarish
Aarish 2023 年 3 月 1 日
回答済み: Abhijeet 2023 年 3 月 7 日
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?

回答 (1 件)

Abhijeet
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

カテゴリ

Help Center および File ExchangeSources についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by