Help with Embedded MATLAB program

Status
Not open for further replies.

necrobutcher

Newbie level 1
Joined
Jun 16, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
I wish to write an embedded MATLAB function which adds a phase shift to a sinusoid. The i/p to the function is the phase shift desired and the o/p will be the phase shifted sinusoid. How should I go about it? I'll be very grateful for any assistance.
 

I wish to write an embedded MATLAB function which adds a phase shift to a sinusoid. The i/p to the function is the phase shift desired and the o/p will be the phase shifted sinusoid. How should I go about it? I'll be very grateful for any assistance.


Hi Copy the following code and paste in Embedded Matlab Function block in Simulink.

function [x,y] = fcn(u) % Output x is the sine wave and y is 'u' times phase shifted sine wave where u is a phase shift desired ie its a constant
%#eml
eml.extrinsic('plot');
t = 0i/100:2*pi;
y = sin(t-u); % Phase shifted Sine wave
x = sin(t); % Original sine wave
plot(t,x,'--',t,y,':');
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…