How to change matrix dimensions (Sigma Delta ADC Simulation)

조회 수: 2 (최근 30일)
Den Sh
Den Sh 2015년 3월 27일
답변: Luuk van Oosten 2015년 6월 3일
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
XING HUANG
XING HUANG 2015년 6월 3일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Luuk van Oosten
Luuk van Oosten 2015년 6월 3일
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!

카테고리

Help CenterFile Exchange에서 Measurements and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by