Matlab function inside Simulink gives parse error
34 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Wouter
le 3 Juin 2013
Réponse apportée : Christopher Magana
le 30 Nov 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 commentaire
Kaustubha Govind
le 3 Juin 2013
Modifié(e) : Kaustubha Govind
le 3 Juin 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.
Réponse acceptée
Plus de réponses (2)
Dragoș Vasile
le 10 Avr 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 commentaires
Christopher Magana
le 30 Nov 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 commentaires
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!