Using Embedded Matlab Function
Show older comments
Good Day!
Please consider the following:
I want to generate a Square wave using the Matlab function: sqaure(),in Simulnk using "Emebedded Matlab Function". I tried the same by using the 'eml.extrinsic'; But i keep getting an error which states :- Function output 'y' cannot be of MATLAB type. Please see following code:
function y = fcn(~)
%#eml
eml.extrinsic('square');
a=1;
dc = 50;
for i=1:100
f=(6908:1:9856)';
f=f*2*pi;
t=0:0.5:22;
y=a*square(f*t,dc); %ERROR
end;
THe Embedded Function Block has no input; only 1 output and a Clock trigger. I am not able to upload images. SOrry for that.
The idea behind this block is to generate a square wave based on the defined frequency range. •a = amplitude •f = frequency •dc = duty cycle
Please let me know what I'm doing wrong? Or point me to what I have to read in order to understand my error? Or provide alternative methods to accomplish what I want.
Accepted Answer
More Answers (1)
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!