Work with Symbolic Math Toolbox with units and export data to Simulink´s models parameters

1 view (last 30 days)
Dear,
I am working with the Symbolic Math Toolbox with units. I would like to pass the results of the calculations as parameters for Simulink models and I cannot find the form. It seems that I have to use the "double" function but I don't know if it is correct when the symbolic variable has units. What would be the correct procedure?
fRed = 50;
Vpk = 1;
R_serie = 10;
u = symunit;
syms Lm Ac mu0 Reluc_AG Reluc_Nucleo L_AG L_HV L_LV
syms Reluc(L,Sec,mu_rel) L_ind(Nvueltas,Reluctancia)
mu0 = 4*pi*1e-7 * (u.Wb / (u.m * u.Ampere));
vpa(mu0,5)
%Definición de la función de la reluctancia
Reluc(L,Sec,mu_rel) = L / (mu0 * mu_rel * Sec)
%Definición de la función de la inductancia
L_ind(Nvueltas,Reluctancia) = Nvueltas^2/Reluctancia
L_AG = 0.5*u.mm; % Largo del entrehierro
vpa(L_AG,5)
Lm = 29.8*u.cm; % Largo promedio del núcleo magnético
vpa(Lm,5)
Ac = 7.8*u.cm^2; % Sección del núcleo
vpa(Ac,5)
N_HV = 75; % Número de vueltas del lado HV
N_LV = 240; % Número de vueltas del lado LV
mu_r = 16600; % permebilidad relativa del núcleo AMCC-200. Dato extraído del Informe Final v2.
%Reluctancia del entrehierro
Reluc_AG = vpa(simplify(Reluc(L_AG, Ac, 1)),10)
%Reluctancia del núcleo
Reluc_Nucleo = vpa(simplify(Reluc(Lm, Ac, mu_r)),10)
%Reluctancia total. Dos veces la reluctancia del entrehierro más la reluctancia del núcleo.
Reluc_Total = vpa(2*Reluc_AG + Reluc_Nucleo,10)
%Inductancia del bobinado HV solo en el núcleo
L_HV = vpa(L_ind(N_HV,Reluc_Total),10);
L_HV = vpa(unitConvert(L_HV,u.mH),5)
%Inductancia del bobinado LV solo en el núcleo
L_LV = vpa(L_ind(N_LV,Reluc_Total),10);
L_LV = vpa(unitConvert(L_LV,u.mH),5)
L_LV_dato = double(L_LV)->ERROR
Thank you very much
Greetings
Juan

Accepted Answer

Ameer Hamza
Ameer Hamza on 4 Oct 2020
As the error message also mentions, you need to use separateUnits before converting it to double
L_LV_dato = double(separateUnits(L_LV))

More Answers (0)

Categories

Find more on Specialized Power Systems in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!