One-time data import into Simulink

5 ビュー (過去 30 日間)
Panagiotis
Panagiotis 2023 年 6 月 26 日
コメント済み: Panagiotis 2023 年 6 月 26 日
Hello there!
I am trying to import a 10001x5 matrix into Simulink, that contains weather data for different altitudes (each row represents an altitude). This dataset will be used as input to a dynamic model of an aircraft. The problem requires that, based on the current altitude of the aircraft the corresponding row of the dataset should be chosen in order to retrieve the data (wind speed, temperature etc.) for that particular altitude. The dynamic simulation does not have a fixed sample time (or simulation step fro that matter, I don't what the difference is at the moment) and for that reason I find it difficult to use the "From Workspace" etc. blocks that are typically used for such purposes. The best way to treat this kind of data, would be to execute a one-time import into the model workspace and retrieve the data needed based on the method described above. The data are saved as a .mat file using the save() function from matlab and are a product of another matlaba function, not included into the simulation.
Do you have any suggestions? Is there a better way to incorporate such a dataset into the simulation?
P.S. For the time being I am using the load() function inside a matlab function block, but this makes the simulation quite slow. I have also tried importing the data as a timeseries, either by using the corresponding blocks or via the model worskpace (inserting my own matlab script, directly importing the data as a structure). Any suggestions would be valuable!

採用された回答

Fangjun Jiang
Fangjun Jiang 2023 年 6 月 26 日
What you need to do are:
  1. Load the 10001x5 matrix into MATLAB base workspace. This just needs to be done once and can be done through a separate M script or the PreLoadFcn callback of the Simulink model.
  2. In the model, use a Lookup Table block. You will need to make the 10001x5 matrix into the right format.
  3. The input to the Lookup Table block is the dynamic altitude value, the output would be the weather data.
The "From Workspace" block is kind of a "Lookup Table" block, but it is "looked up" on time, not on any other variable.
  1 件のコメント
Panagiotis
Panagiotis 2023 年 6 月 26 日
Thank you very much! Your answer was very helpful and it actually saved me from a couple of days of searching!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by