Can vpasolver work in simulink model?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Paris Pasqualin
el 3 de Dic. de 2020
Comentada: Paris Pasqualin
el 14 de Jun. de 2022
Hello to everyone,
I wanted to create a function block on simulink with outputs calculated from the solution of vpasolver. When I run the simulink model I get an error saying
"Function 'syms' not supported for code generation. Function 'MATLAB Function' (#35.101.118), line 3, column 1: "syms Qp cp Qb cb" Launch diagnostic report."
Does this mean that vpasolver can't work on simulink? If yes, could there be a way to use it? Beneath it's the function I'm referring to.
Best regards,
Paris
function [Qp,cp,Qb,cb] = fcn(Q_in,c_in,r,P,i,T)
R = 0.0832; % Universal gas constant [L*atm/(K*mol)]
syms Qp cp Qb cb
S = vpasolve(r == 1-cp/c_in, Q_in == Qp+Qb, Q_in*c_in == Qp*cp + Qb*cb, P/(i*R*(T+273.15)) == cb-cp, [Qp cp Qb cb]);
Qp = S.Qp;
cp = S.cp;
Qb = S.Qb;
cb = S.cb;
0 comentarios
Respuesta aceptada
Uday Pradhan
el 16 de Dic. de 2020
Editada: Uday Pradhan
el 16 de Dic. de 2020
Hi,
I think a possible workaround to this would be to do the symbolic computations in a separte function script and call that function from your block as an extrinsic function. Example: Define 'fcn.m' that contains all the computations:
function [qp,cp,qb,cb] = fcn(Q_in,c_in,r,P,i,T)
R = 0.0832; % Universal gas constant [L*atm/(K*mol)]
syms Qp cp Qb cb
S = vpasolve(r == 1-cp/c_in, Q_in == Qp+Qb, Q_in*c_in == Qp*cp + Qb*cb, P/(i*R*(T+273.15)) == cb-cp, [Qp cp Qb cb]);
qp = double(S.Qp);
cp = double(S.cp);
qb = double(S.Qb);
cb = double(S.cb);
end
Then in the MATLAB function block call:
function [Qp,cp,Qb,cb] = fcn1(Q_in,c_in,r,P,i,T)
coder.extrinsic('fcn');
Qp = 0;
cp = 0;
Qb = 0;
cb = 0;
[Qp,cp,Qb,cb] = fcn(Q_in,c_in,r,P,i,T);
I hope this helps!
4 comentarios
Gordon
el 13 de Jun. de 2022
I get the error that numvars = 0. So it's as if still not evaluating variables.
Más respuestas (0)
Ver también
Categorías
Más información sobre General Applications en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!