Solve system of equations in simulink
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Ankita Nargundkar
el 22 de Jun. de 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 comentarios
Ver también
Categorías
Más información sobre Symbolic Math Toolbox 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!