how can i implement transfer function in embedded matlab block?

10 views (last 30 days)
i need to generate a matlab code for a transfer function whose coefficient varies depending on frequency.In embedded matlab block i used the same way to generate transfer function code as in m-file. but it shows error.how can i implement transfer function in embedded matlab block?
  2 Comments
Reshna
Reshna on 19 Jul 2014
The program is as follows;
function y = fcn(I,w) eml.extrinsic('tf')
s = tf('s'); a=0.4*w*s/(s^2+(2*w*s)+887364); b=0.4*w*s/(s^2+(2*w*s)+2464900); c=0.4*w*s/(s^2+(2*w*s)+4831204); d=0.4*w*s/(s^2+(2*w*s)+7986276);
y = I*(a+b+c+d); And the error messages are: 1) Expected either a logical, char, int, fi, single, or double. Found a MATLAB type. MATLAB types are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may be used on the right-hand side of assignments and as arguments to MATLAB calls.
Function 'Embedded MATLAB Function' (#18.68.71), line 6, column 12: "s^2" 2)Undefined function or variable 'a'. The first assignment to a local variable determines its class.
Function 'Embedded MATLAB Function' (#18.196.197), line 11, column 8: "a" 3)Errors occurred during parsing of Embedded MATLAB function 'Embedded MATLAB Function'(#18) 4)Embedded MATLAB Interface Error: Errors occurred during parsing of Embedded MATLAB function 'Embedded MATLAB Function'(#18)

Sign in to comment.

Answers (2)

Rick Rosson
Rick Rosson on 18 Jul 2014
doc coder.extrinsic
  1 Comment
Reshna
Reshna on 20 Jul 2014
The program is as follows;
function y = fcn(I,w) eml.extrinsic('tf')
s = tf('s'); a=0.4*w*s/(s^2+(2*w*s)+887364); b=0.4*w*s/(s^2+(2*w*s)+2464900); c=0.4*w*s/(s^2+(2*w*s)+4831204); d=0.4*w*s/(s^2+(2*w*s)+7986276);
y = I*(a+b+c+d); And the error messages are: 1) Expected either a logical, char, int, fi, single, or double. Found a MATLAB type. MATLAB types are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may be used on the right-hand side of assignments and as arguments to MATLAB calls.
Function 'Embedded MATLAB Function' (#18.68.71), line 6, column 12: "s^2" 2)Undefined function or variable 'a'. The first assignment to a local variable determines its class.
Function 'Embedded MATLAB Function' (#18.196.197), line 11, column 8: "a" 3)Errors occurred during parsing of Embedded MATLAB function 'Embedded MATLAB Function'(#18) 4)Embedded MATLAB Interface Error: Errors occurred during parsing of Embedded MATLAB function 'Embedded MATLAB Function'(#18)

Sign in to comment.


MOUMITA DEY
MOUMITA DEY on 24 Jun 2017
how do i implement[(((1/T)*log(1+T*u))+1)/((10*(((1/T)*log(1+T*u))^3.2))+(185*(((1/T)*log(1+T*u))^2.5))+(288*(((1/T)*log(1+T*u))^0.7))+1)] as a transfer function in matlab where T is samplying time and u is gama

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!