invalid use of matlabfunction 'tablelookup' in simscape component

2 visualizaciones (últimos 30 días)
maarten de Jong
maarten de Jong el 3 de Feb. de 2020
Respondida: Danvir Sethi el 2 de Mzo. de 2020
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

Respuestas (1)

Danvir Sethi
Danvir Sethi el 2 de Mzo. de 2020
You need to define 'R' as a variable
variables
i = {1,'A'}; % electrical current
v = {1,'V'}; % voltage
R = {1, 'Ohm'};
end

Categorías

Más información sobre Equations en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by