- MATLAB script, MAT file, Simulink Model to reproduce the issue at my end.
Import Timeseries on Simulink as raw structure and not as single data samples at certain simulation time
3 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am working on a Model Predictive Control on Simulink requiring a reference signal that is something like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1235247/image.png)
where P is the prediction horizon ( the reference changes during the prediction horizon).
Without getting into too many unnecessary details, I created a timetable of reference values, and since the system is MIMO and Simulink accepts only timetables with one variable, i converted it to a timeseries to have a single structure with all the output references. I know it seems not smart, but I found working with timetables be easier for me and my kind of problem, thus I have a timeseries tms with ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1235252/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1235252/image.png)
On Simulink, I wanted to connect after a From Workspace Block a Matlab Function Block (MFB) that simply does
dinamically with t the current simulation time, thus giving to the MPC Block the correct changing reference.The command that does this in the MFB is getsampleusingtime(y_ref, t, t+(P-1)*time_sample_of_tms);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1235257/image.png)
The problem is: Simulink gives to the MFB only the row of tms that is referred to the current time and not the whole timeseries every instant of the simulation, so i cannot apply my approach. I also tried the Constant Block, but returns errors.
Do you have any solution or wiser approach to solve this situation,
Thank you in advance,
GM.
1 件のコメント
Suvansh Arora
2022 年 12 月 22 日
In order to understand this better, can you provide the following information:
回答 (1 件)
Emmanouil Tzorakoleftherakis
2023 年 1 月 25 日
It seems to me that you want to implement the MPC preview capability in Simulink. This example actually has a custom previewer block that implements exactly what you need.
Hope that helps
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Model Predictive Control Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!