how to automatically creat sldd file based on csv file

i add following info to CSV file, how to use this CSV file to creat sldd file automatically.

4 件のコメント

Walter Roberson
Walter Roberson 2024 年 2 月 7 日
To confirm: you want to create a Simulink Data Dictionary ?
wenchao zhang
wenchao zhang 2024 年 2 月 7 日
yes,that's what i want.
wenchao zhang
wenchao zhang 2024 年 2 月 8 日
thank you.

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

 採用された回答

Yash
Yash 2025 年 1 月 31 日

1 投票

Hi Wenchao,
You can use the "readtable" function to read the csv. Refer to the following documentation for more details: https://www.mathworks.com/help/matlab/ref/readtable.html
Further, you can use the functions mentioned in the following article to store data programmatically in the data dictionary: https://www.mathworks.com/help/simulink/ug/store-data-in-dictionary-programmatically.html
Given below is an example code:
T = readtable("data.csv");
ddConn = Simulink.data.dictionary.open('dTmp.sldd');
ddSec = ddConn.getSection('Design Data');
for i=1:height(T)
ddSec.addEntry(T.Name{i},T.Value(i));
end
ddConn.saveChanges;
Note that if the entry with the name already exists, "addEntry" will throw error. Use "assignin" in those cases.
Hope this helps.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

製品

リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by