Matlab function inside Simulink gives parse error
35 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Wouter
el 3 de Jun. de 2013
Respondida: Christopher Magana
el 30 de Nov. de 2018
I have included the Matlab Function block in a Simulink diagram to call a matlab function, http://www.mathworks.nl/help/simulink/slref/matlabfunction.html.
Now when I want to simulate the Simulink diagram I get the error:
Errors occurred during parsing of MATLAB function 'MATLAB Function'(#384)
I however do not find any errors in my matlab function script:
function out = Sigma(xyz,x1,u)
x = xyz(1);
y = xyz(2);
z = xyz(3);
out = [-x^3 + 3*x + 2 + 5*y - z + u; ...
-0.8 - x^2 - 2*x - y; ...
0.005*(4*(x1 + 1.77) - z)];
end
The input xyz is a mux-ed signal with length 3, x1 and u are scalar values.
So what is going wrong? Can anyone look threw my files?
It contains three files. - main.m, the main file in some variables are declared and which runs the simulink model - Sigma.m, a copy of the matlab function - HindmarshRose.mdl, the simulink model.
1 comentario
Kaustubha Govind
el 3 de Jun. de 2013
Editada: Kaustubha Govind
el 3 de Jun. de 2013
Please scroll down through the list of errors in the popup window and see if you can find more details about the error, especially one pointing to a line number in your code.
Respuesta aceptada
Más respuestas (2)
Dragoș Vasile
el 10 de Abr. de 2014
Hello,
I have the same problem and I have already tried to put the output size but the error still appears.
The code is in a Matlab function in Simulink.
Here is my code:
function [ Ts, Tq ] = Ts_function( PWM ) %THRUST_AND_TORQUE Summary of this function goes here % Detailed explanation goes here
P = [1000 1200 1500 1600 1650 1700 1750 1800 1850 1900 1950 2000];
Fq= [0 50 75 84 91 94 100 109 113 119 121 125];
RPM = Fq * 60;
Ts1 = 8.9e-7*RPM.^2.3314;
Tq1 = 1.0798e-005*Ts1;
Thrust = interp1(P,Ts1,PWM,'spline'); Torque = interp1(P,Tq1,PWM,'spline');
end
0 comentarios
Christopher Magana
el 30 de Nov. de 2018
I have the same problem and all I'm trying to do is use Bitconcat in simulink...It is not even my function and its throwing an error for it.
0 comentarios
Ver también
Categorías
Más información sobre Simulink Functions 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!