Solve system of equations in simulink
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I wrote a script to solve a system of 3 equations in matlab. The code can be seen below. I need to add this in simulink simulink's matlab function block does not support symbolic variables. I would just leave everything in matlab but there is already a simulation in Simulink that I need to add this matlab function block to. Does anyone have any suggestions on how I can execute this matlab script in simulink?
syms u dt u_z
hf = 0;
u0 = 16;
Alt = 69.96;
dz = hf - Alt;
a = 2;
theta = 35;
phi = 10;
ax = a*cosd(theta)*cosd(phi);
ay = a*sind(theta)*cosd(phi);
az = a*sind(phi) - 9.8;
f1 = 0 == u0 + a*dt - u;
f2 = 0 == u*sind(phi) - u_z;
f3 = 0 == (u_z - sqrt(2*az*dz + u_z^2)/az) - dt;
[u, u_z, dt] = solve([f1, f2, f3], [u, u_z, dt]);
0 commentaires
Réponses (1)
Ankita Nargundkar
le 22 Juin 2017
Use 'matlabFunction' to create a numerical equivalent of the symbolic expressions. Refer to this link
For example:
matlabFunction(u, u_z, dt,'file','sysEqn')
Will create 'sysEqn.m' that gives the numerical values of u, u_z, dt. You can parameterize the resulting function by making sure any parameters are defined as 'syms' in the original symbolic code.
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!