invalid use of matlabfunction 'tablelookup' in simscape component

조회 수: 3 (최근 30일)
maarten de Jong
maarten de Jong 2020년 2월 3일
답변: Danvir Sethi 2020년 3월 2일
I keep getting an error when I try to run a simle electrical circuit with my custom resistor connected.
The error occursin the line (in the equations section) where I define R as a function of Temperature [T] and State of Charge (of the battery cell) [SoC].
R == tablelookup(Td, SoCd, R_tab, T, SoC, interpolation = smooth);
I have defined SoCd as a 1 x 11 vector ranging from 0 to 1 .
I have defined Td as 1 x 3 vector ranging from 273.15 'K' to 313.15 'K' .
I have defined the table with values for R as R_tab, which is a 11 x 3.
What is going wrong in my code?
component MyElecResistor
% Electrical resistor
% This electrical resistor featues a constant electrical resistance
% This electrical resistance generates a heatflow as P=I*V=I*I*R
%Declarations
variables
i = {1,'A'}; % electrical current
v = {1,'V'}; % voltage
end
parameters
Td = {[273.15, 293.15, 313.15], 'K'} % breakpoints temperature
SoCd ={[0: 0.1: 1],'1'} % breakpoints state of charge
R_tab = { [0.012, 0.009, 0.0085;
0.012, 0.009, 0.0085;
0.0118, 0.0091, 0.0086;
0.0112, 0.009, 0.0085;
0.017, 0.0089, 0.0084;
0.011, 0.0088, 0.0082;
0.0109, 0.009, 0.0083;
0.0109, 0.0091, 0.0084;
0.0108, 0.0092, 0.0084;
0.0116, 0.009, 0.0085;
0.012, 0.0089, 0.0085], 'Ohm'}; % table values of R
end
inputs
T = {298.15, 'K'}; % T:left
SoC = {1, '1'}; % SoC:left
end
outputs
pow = {0.3, 'W'}; % pow:right
end
nodes
pos = foundation.electrical.electrical; % +:left
neg = foundation.electrical.electrical; % -:right
end
%Relationships
branches
i: pos.i -> neg.i;
end
equations
R == tablelookup(Td, SoCd, R_tab, T, SoC, interpolation = smooth);
assert(T<={313.15, 'K'})
assert(T>={273.15, 'K'})
assert(SoC>=0)
assert(SoC<=1)
v == pos.v - neg.v;
v == i*R;
pow == i*v;
end
end

답변 (1개)

Danvir Sethi
Danvir Sethi 2020년 3월 2일
You need to define 'R' as a variable
variables
i = {1,'A'}; % electrical current
v = {1,'V'}; % voltage
R = {1, 'Ohm'};
end

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by