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.

pls help me... MATLAB function problem

Status
Not open for further replies.

baya

Newbie level 1
Joined
Sep 3, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
malaysia
Activity points
1,304
bpsk=cp.*mod

function askd(g,f)
%Modulation ASK
%Example:
%askd([1 0 1 1 0],2)
objectId=14328&objectType=FILE
if nargin >2
error('Too many input arguments')
elseif nargin ==1
f=1;
end

if f<1;
error('Frequency must be bigger than 1')
end

t=0:2*pi/99:2*pi;
cp=[];sp=[];
mod=[];mod1=[];bit=[];

for n=1:length(g);
if g(n)==0;
die=ones(1,100);
se=zeros(1,100);
else g(n)==1;
die=2*ones(1,100);
se=ones(1,100);
end
c=sin(f*t);
cp=[cp die];
mod=[mod c];
bit=[bit se];c
end

ask=cp.*mod;
subplot(2,1,1);plot(bit,'LineWidth',1.5);grid on;
title('Binary Signal');
axis([0 100*length(g) -2.5 2.5]);

subplot(2,1,2);plot(ask,'LineWidth',1.5);grid on;
title('ASK modulation');
axis([0 100*length(g) -2.5 2.5]);

function fskd(g,f0,f1)
%FSK modulation
objectId=a4328
objectType=FILE
if nargin >3
error('Too many input arguments')
elseif nargin==1
f0=1;f1=2;
elseif nargin==2
f1=2;
end

va10=ceil(f0)-f0;
va11=ceil(f1)-f1;
if val0~=0 || val1 ~=0;
error('Frequency must be an integer');
end

if f0<1 || f1<1;
error('Frequency must be bigger than 1');
end

t=0:2*pi/99:2*pi;
cp=[];sp=[];
mod=[];mod1=[];bit=[];

for n=1:length(g);
if g(n)==0;
die=ones(1,100);
c=sin(f0*t);
se=zeros(1,100);
else g(n)==1;
die=ones(1,100);
c=sin(f1*t);
se=ones(1,100);
end
cp=[cp die];
mod=[mod c];
bit=[bit se];
end

ask=cp.*mod;
subplot(2,1,1);plot(bit,'LineWidth',1.5);grid on;
title('Binary Signal');
axis([0 100*length(g) -2.5 2.5]);

subplot(2,1,2);plot(ask,'LineWidth',1.5);grid on;
title('FSK modulation');
axis([0 100*length(g) -2.5 2.5]);


function bpskd(g,f)
%Modulation BPSK
objectId=14328
objectType=FILE
if nargin > 2
error('Too many input arguments');
elseif nargin==1
f=1;
end

if f<1;
error('Frequency must be bigger than 1');
end

t=0:2*pi/99:2*pi;
cp=[];sp=[];
mod=[];mod1=[];bit=[];

for n=1:length(g);
if g(n)==0;
die=-ones(1,100);
se=zeros(1,100);
else g(n)==1;
die=ones(1,100);
se=ones(1,100);
end
c=sin(f*t);
cp=[cp die];
mod=[mod c];
bit=[bit se];
end

bpsk=cp.*mod
subplot(2,1,1);plot(bit,'LineWidth', 1.5);grid on;
title('ASK modulation');
axis([0 100*length(g) -2.5 2.5]);





i got this source code from my lect...but when im running this source code..there are an error which are cannot define the function of variable objectType...

can somebody help me to solve this prob.

TQ!
 

ask modulation source code

my friend, these are just functions which must be recalled by other code.

try to type in the matlab prompt the following:

help function

and see the results
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top