一. Description
此脚本主要用于将DD文件中的变量值更新为Excel中的数据。
二. Background
基于Targetlink进行MBD开发时,用Excel管理DD文件中的Table变量值。(一维,二维Look-up table均可)。
Note:当更新Look-up table一维变量时,需要在Excel中,先将列转置为行。例如,下图中电压更新到DD中,将呈现为
[2.837,3.29,3.384,3.447,3.504,3.544,3.581,3.612,3.642,3.676,3.722,3.778,3.84,3.887,3.924,3.973,4.031,4.064,4.075,4.096,4.19]
三. Value in Excel
以如下Excel为例
四. Code
%The script is used to change the Values of variable with the data in xlsx file
filename = 'C:/Work/Model/TimeSolve/Table.xlsx'; %Set the xlsx file location here
sheet = 2; %Sheet number set
xlRange = 'B3:D23'; %Range select
subsetA = xlsread(filename,sheet,xlRange);
dsdd('Open','Table.dd'); %Open the DD file to be modified
dsdd('Set','/Pool/Variables/batlib/lut/OCV-SOC','Value',subsetA);
五. Result
懒得截图了🤣