how to automatically creat sldd file based on csv file

조회 수: 4 (최근 30일)
wenchao zhang
wenchao zhang 2024년 2월 7일
댓글: wenchao zhang 2025년 2월 2일
i add following info to CSV file, how to use this CSV file to creat sldd file automatically.
  댓글 수: 4

댓글을 달려면 로그인하십시오.

채택된 답변

Yash
Yash 2025년 1월 31일
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개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by