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.

Matlab help ! need to digitally modulate a sine wav

Status
Not open for further replies.

jess17

Junior Member level 3
Joined
Mar 4, 2011
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,431
ok i need to do FSK on a sine wave, but i keep getting an error saying

" ??? Error using ==> dpskmod at 41
Elements of input X must be integers in the range [0, M-1].

Error in ==> dpskmodulation at 15
sig = dpskmod(x,M,pi / 8 ) ; "



my code is as follows:


M = 4; % Use DQPSK in this example, so M is 4.
Fs = 100;
t = [0:2*Fs+1]'/Fs;
Fc = 10; % Carrier frequency
x = sin(2*pi*t); % Sinusoidal signal
figure(1)
plot(t, x);

sig = dpskmod(x,M,pi / 8 ) ;
figure(2)
plot(y) % Plot all points, using lines to connect them.
 

ok i need to do FSK on a sine wave, but i keep getting an error saying

" ??? Error using ==> dpskmod at 41
Elements of input X must be integers in the range [0, M-1].

Error in ==> dpskmodulation at 15
sig = dpskmod(x,M,pi / 8 ) ; "



my code is as follows:


Code:
[COLOR="blue"]M = 4; % Use DQPSK in this example, so M is 4.
Fs = 100;
t = [0:2*Fs+1]'/Fs;
Fc = 10; % Carrier frequency
[COLOR="red"][U][B]x = sin(2*pi*t); % Sinusoidal signal[/B][/U][/COLOR]
plot(t, x);

[B][U]sig = dpskmod(x,M,pi / 8 ) ;[/U][/B][I][COLOR="red"]%here x must be an integer below m-1[/COLOR][/I]
figure(2)
plot(y) % Plot all points, using lines to connect them.
[/COLOR]

i think the problem is in the highlighted portion .
Instead of integers you have non integer array
 

well, i tried multiplying bi 1000, and then plotting the abs values, so I get only 0's and 1's for x, I am still getting the same error
 

well, i tried multiplying bi 1000, and then plotting the abs values, so I get only 0's and 1's for x, I am still getting the same error

Hi

jess

one solution is to generate a sine wave then sample the sine wave then Quantize the sample output.After Quantization the output will be just binary sequence Then you can apply the matlab function dpskmod() or fskmod() .


this link got a good explanation on Quantization
h**p://www.mathworks.com/matlabcentral/answers/2952-quantisation-using-matlab
 

ok here is what i did to quantize:

>> t = [0:.1:2*pi]; % Times at which to sample the sine function
sig = sin(t); % Original signal, a sine wave
partition = [-1:.2:1]; % Length 11, to represent 12 intervals
codebook = [-1.2:.2:1]; % Length 12, one entry for each interval
[index,quants] = quantiz(sig,partition,codebook); % Quantize.
plot(t,sig,'x',t,quants,'.')
legend('Original signal','Quantized signal');
axis([-.2 7 -1.2 1.2])
>>
>> M = 4;
>> y = dpskmod(quants,M,pi / 8 ) ;


but i still keep getting the error
??? Error using ==> dpskmod at 41
Elements of input X must be integers in the range [0, M-1].
 

[/B Let me ask one Question ,What's your Exact need FSK or PSK ....
here as per the problem given i infer two things

1.Your Carrier is Sinusoidal 100hz
2.Modulating Signal 10hz Sinusoidal

I think this thread can solve your problem it's quite similar to what you specified .
h**p://https://www.edaboard.com/threads/133432/


Here is another good material on FSK Containing Matlab Code

h**p://www.ece.udel.edu/~barner/courses/eleg212/laboratories/Lab_05.pdf
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top