Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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 = 0:pi/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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top