How to change matrix dimensions (Sigma Delta ADC Simulation)

1 view (last 30 days)
Hi all,
I am simulating a Sigma Delta Modulator of 2nd order with SDT toolbox(by S. Brigati). There is an example .m file working with .mdl file of a 2nd order delta sigma modulator. Everything works fine till I try to change the order of the example modulator, then running of .m file gives me following error:
*Index exceeds matrix dimensions.
Error in SD2_ (line 88) yy1=yout(2+Ntransient:1+N+Ntransient)';
with following code (line 88 is the last one):
options=simset('InitialState', zeros(1,2), 'RelTol', 1e-3, 'MaxStep', 1/Fs);
sim('sd1', (N+Ntransient)/Fs, options); % Starts Simulink simulation
% ************************************************************************
% Calculates SNR and PSD of the bit-stream and of the signal
% ************************************************************************
w=hann(N);
echo on;
f=Fin/Fs ;% Normalized signal frequency
fB=N*(bw/Fs) ;% Base-band frequency bins
yy1=zeros(1,N);
yy1=yout(2+Ntransient:1+N+Ntransient)';
Parameters:
bw=1000; % Base-band
R=256;
Fs=R*2*bw; % Oversampling frequency
Ts=1/Fs;
N=65536; % Samples number
nper=12;
Fin=nper*Fs/N; % Input signal frequency (Fin = nper*Fs/N)
Ampl=0.5-pi/256; % Input signal amplitude [V]
Ntransient=0;
I am new in matlab and can't get it fixed by myself. Please help me :) Thx!
  1 Comment
XING HUANG
XING HUANG on 3 Jun 2015
Hi,I'm studying Sigma-Delta modulator, too. And I also use the toolbox of SDT. Can we make friends and design the SDM together?

Sign in to comment.

Answers (1)

Luuk van Oosten
Luuk van Oosten on 3 Jun 2015
What you are trying to do is taking a value (which you try to index) but it does not exist, because it exceeds the dimensions of the matrix. Here is an example of what is happening:
Imagine you have the 3x3 matrix called 'a'.
a=[1 2 3;6 1 8; 9 1 5]
find a(3,3) (or any other value; a(1,2))
a(3,3) = 5
now try to find a(4,3).
Index exceeds matrix dimensions.
for the obvious reason that you try to to look in the 4th row (while the matrix 'a' only has 3 rows...)... ergo: your index (4,2) is exceeding the matrix dimensions.
The same thing is happening in your line 88. Without the rest of the code and what your are trying to do it is hard to tell what exactly is going wrong, but take a look at this (line 87 and 88):
yy1=zeros(1,N);
yy1=yout(2+Ntransient:1+N+Ntransient)';
which tells you (by the info your provided):
yy1 = zeros(1, 65536);
yy1 = yout(2+0 : 1+65536+0)';
Good luck!

Categories

Find more on Measurements and Feature Extraction in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!