Matlab function inside Simulink gives parse error
조회 수: 21 (최근 30일)
이전 댓글 표시
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
Kaustubha Govind
2013년 6월 3일
편집: Kaustubha Govind
2013년 6월 3일
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.
채택된 답변
추가 답변 (2개)
Dragoș Vasile
2014년 4월 10일
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
Christopher Magana
2018년 11월 30일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!