简体   繁体   中英

How to use 3D surface data from cftool in Simulink lookup table?

I am designing a battery model with an internal resistance which is dependant on two variables: SoC and temperature.

I have interpolated the data I have (x,y and z basically - a total of 131 points each) with MATLAB's curve fitting toolbox and was able to generate the desired 3D map of that dependence (see the picture below):

Matlab曲线拟合工具箱中的数据

My question is how can I use that map now for my Simulink model? As input parameters I will have SoC and temperature and the resistance in ohm should be the output. However, I have not been able to find a convenient way to export the data in a suitable lookup table (or similarly useful, my first guess was that I should use a 2-D lookup table in this case) in Simulink. However, I am quite new to this and I do not know how to generate the the table data for the Simulink LUT.

Simulink LUT:

Table data is your interpolated z-data from curve fitting. I guess it will have a value for every combination of breakpoints (ie it covers every grid intersection in your first diagram). So if Breakpoint 1 is 100 elements and Breakpoint 2 is 40 elements, Table data is 100x40.

If you can't get the data out from the GUI-based interactive curve fit, I guess you can extract the data from the command line. The following is an excerpt of Mathworks' curve fitting documentation. It would be good to verify this because I don't have the toolbox to test it though.

•Interpolation: fittedmodel = fit([Time,Temperature], Energy, 'cubicinterp');
•Evaluation: fittedmodel(80, 40)

Based on your LUT inputs u1 and u2, the table will interpolate or extrapolate the grid to get your output value.

Hope that helps.

I did find a solution after all, thanks Tom for your help, the fittedmodel() function was indeed the key of it. I then used two FOR loops to populate my matrix which was 49x51 (as seen by the grid in the image) after the cftool interpolation. After that it was all a matter of two for loops in one another to populate my matrix with the z values of my T and SoC parameters.

插值图

for x = 1:49
for y = 1:51
    TableData(x,y)=fittedmodel(B_SoC(x),B_Temp(y));
end
end

Where TableData is the 49x51 matrix required for my LUT, B_SoC and B_Temp being [0:2.083:100] and [-10:1.1:45] respectively (determined as the desired start and end of my x and y axis with the spacing taken from the image with the data cursor).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM