Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
what is wrong with this code, please help!

Subject: what is wrong with this code, please help!

From: jessica david

Date: 13 Mar, 2011 15:32:04

Message: 1 of 2

>> 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].

Subject: what is wrong with this code, please help!

From: Wayne King

Date: 13 Mar, 2011 16:25:04

Message: 2 of 2

"jessica david" wrote in message <ilio1k$pvd$1@fred.mathworks.com>...
> >> 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].

Hi Jessica, your codebook contains non-integer values. dpskmod() only accepts non-negative integer inputs.

Wayne

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us