0

I am not able to get this error removed. Can someone please help me. The problem is it is showing some error in step 4 while generation of hdl code.

 function [Rxx]=autom(X)    % [Rxx]=autom(x)
Rxx=zeros(1,1024);
for m=1: 1025
for n=1: 1025-m
Rxx(m)=Rxx(m)+X(n)*X(n+m-1);

end
end

%testbench

N=1024;                            % Number of samples
f1=1;                              % Frequency of the sinewave
FS=200;                            % Sampling Frequency
n=0:1023;                           % Sample index numbers
X=zeros(1,1024);
% X=sin(2*pi*1*(0:1023)/200);
X=sin((2*pi*1.*n)./200);
t=[1:1024]*(1/200);
%ti=f1*n/FS;
%x=sin(2*pi*ti);                    % Generate the signal, x(n) 
%t1=[1:N]; 
%t=t1*(1/FS);                          % Prepare a time axis

subplot(2,1,1);                    % Prepare the figure
plot(t,X);        
title('Sinwave of frequency 1000Hz [FS=8000Hz]');
xlabel('Time, [s]');
ylabel('Amplitude');
grid;

Rxx = autom(X(1:1024));                                % Calculate its autocorrelation
subplot(2,1,2);
plot(Rxx);
title('Autocorrelation function of the sinewave'); % Plot the autocorrelation 
xlabel('lags');
ylabel('Autocorrelation');

Errors i am getting

1 Answer 1

0

The error says: "[...] unsuported dynamic matrix X[...]"

Your problem is that in your function you are doing X(n)*X(n+m-1); and it seem to be understanding that this is dynamically changing the size of the matrix. I suspect in fact that the error is in Rxx

Note that your X is 1024 on length, but your iterations of n and m are 1025 in length. Rxx is 1024 on length, but you do Rxx(m) and m goes up to 1025, thus dynamically changing its size (MATLAB will increase the size of Rxx from 1024 to 1025, dynamically)

Are you sure you dont want

function [Rxx]=autom(X)    % [Rxx]=autom(x)
Rxx=zeros(1,1024);
for m=1: 1024
  for n=1: 1024-m
    Rxx(m)=Rxx(m)+X(n)*X(n+m-1);
  end
end
Sign up to request clarification or add additional context in comments.

3 Comments

Sorry but i tried that it didnt work. Can you suggest me some way so that i can get rid of dynamic matrix and get it done somehow as scalar?
@maudoodahmed you dont seem to understand what a dynamic matrix is or what a scalar is. A dynamic matrix is a matrix that changes size. The code I provided makes matrices that are not dynamic. But I dont know much about HDL generation code, so I can not help you more than this, apologies
Ok. Thanks alot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.