One-time data import into Simulink

조회 수: 22 (최근 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 CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by