フィルターのクリア

Load array into Simulink model from file without timestamps

21 ビュー (過去 30 日間)
Yvo Lucas
Yvo Lucas 2022 年 10 月 6 日
回答済み: Benjamin Thompson 2022 年 10 月 10 日
Hello MATLAB Community,
im trying to load a big array Q_Matrix_dyneps_smallcargo(25920x30 -in the top of the picture) into my simulink modell. I tried this on multiple ways, but none of them worked for me. I need the values for calculations inside the function block. (i dont show the function cause its multiple hundret lines of code which are not relevant for the question- im using different values in row X and column Y to compute some new variables. But since i dont even get the Q into workspace correctly it wont be helpfull to show the function)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
First i tried to load it with the from-file-block (my favorite option in theory) of simulink but instead of getting the correct dimension i only get the first column loaded (not 30). Of course i read the official explanation of the from-file block, where its said, each column must have a timestamp.
But i dont want to add any timestamps and even if i would want to i dont have any values for that. I dont need the array to simulate but only need the values of the array to use for calculations in the matlab function block. There is no context to time (stamps?) at all with this array.
I would like to load the array as it is...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Second i tried to load it directly inside the function block ( Q = load('Q_Matrix_dyneps_smallcargo','Q') ) which would give me the following failure message:
Expected either a logical, char, int, fi, single, or double. Found a struct.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Third i tried using the from-workspace block by first loading the array into workspace in my matlab command window followed by execution of the simulink model with from-workspace block
error :
Invalid workspace variable specified as workspace input in 'XY_Simulink/From Workspace'. Time values must be non-decreasing.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Main Question:
Is it possible to load the whole matrix into my model without adding any time stampts i dont need at all?
Thank you for all help and answers!
  1 件のコメント
Yvo Lucas
Yvo Lucas 2022 年 10 月 6 日
Wow, before posting it i searched for hours- instantly atfer posting i found a solution / workaround.
But im still interested in a possibility to load it from a file if someone has an idea.
For everybody with same problem here the solution:
Put Variable into Workspace with MATLAB command window or script --> Use constant block in Simulink model with the same name as variable in Workspace.

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

回答 (1 件)

Benjamin Thompson
Benjamin Thompson 2022 年 10 月 10 日
If you define your matrix as a Simulink.Parameter in a data dictionary and link to that data dictionary from your model, that would meet your requirements.

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by