Using predefined OOP in simulink "Matlab function" block

Does anybody know how to implement objects and associated functions (defined by myself in a package) in a simulink "Matlab function" block? I have some problems implementing this piece of code for example:
*function y = fcn(speed,torque)
%#codegen
% mtr = motor.motors.ZR500();
% y = mtr.efficiency(torque*units.Nm,speed*units.rpm,'star');
coder.extrinsic('efficiency','inductionmotor');
mtr = motor.motors.ZR500();
y= mat2str(mtr.efficiency(torque,speed,'star'));
%end*
Errors that I receive from simulink:
*Message - Source - Reported by - Summary*
1) Coder Error - c:/matlab/packages/+motor/inductionmotor.m - Matlab Function - This kind of expression is not supported
2) Coder Error - Matlab function - Matlab function - Parsing failed
3) Block Error - torque - Simulink - Error in port widths or dimensions. Output port 1 is a one dimensional vector with 1 elements.
The reason I use "coder.extrinsic('efficiency','inductionmotor');" is already because I was reading that some function can better be solved in Matlab and simulink will ignore them.
Any help would be highly appreciated! Thanks in advance

1 Comment

Can you try without using the extrinsic call to the class.
coder.extrinsic isn't supported for declaring MATLAB Classes as extrinsic as per http://www.mathworks.com/help/fixedpoint/ug/how-working-with-matlab-classes-is-different-for-code-generation.html.
Also which version of MATLAB are you working with?

Sign in to comment.

Answers (0)

Asked:

on 6 Sep 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!