Iam tying to run the following code on the data,
but it gives me an error:
Error using .* Matrix dimensions must agree.. The error occurs here: xw=x .* xh'; % Window the signal.
Can someone help me?
---------------------------------
DataTbl=readtable('6largeabsorbers100 pointds44.545 msweep2.csv');
[Ro,Co]=size(DataTbl);
Data=table2array(DataTbl);
Frequency=Data(:,1);
S21Mag=Data(:,2);
S21Ang=Data(:,3);
%%% DAta Preperation %%%%%%
[Re,Im]=pol2cart(S21Ang,S21Mag);
CmpLx=complex(Re,Im);
ampitude=sqrt((Re .^2)+(Im .^2)); % amplitude value
ampitudedB= 20*log10(ampitude)+10; % amplitude in dB
plot (Frequency,ampitudedB, 'k'); %Amplitudein db verus time
xlabel('Frequency [Hz]') % x-axis label
ylabel('H(t0,f) [dB]') % y-axis label
title('suburban-6 small absorbers- Time-invariant transfer function')
%--FFT on data
f1=2420000000; % Signal frequency
MD=10; % measurement duration in se
FS=length(data)/MD; % sampling frequency in Hz
N=256; % Number of samples
N1=1024; % Number of FFT points
n=0:N-1; % Index n
f=(0:N1-1)*FS/N1; % Defining the frequency points [axis]
x= ampitudedB/FS;
XR=abs(fft(x,N1)); % find the magnitude of the FFT using No
% windowing (i.e. Rectangular window)
xh=hamming(N); % Define the hamming samples
xw=x .* xh'; % Window the signal
XH=abs(fft(xw,N1)); % find the magnitude of the FFT of the
% windowed signal.
subplot(2,1,1); % Start plotting the signal
plot(f(1:N1/2),20*log10(XR(1:N1/2)/max(XR)));
title('Spectrum of x(t) using Rectangular Windows');
grid;
xlabel('Frequency, Hz');
ylabel('Normalised Magnitude, [dB]');
subplot(2,1,2);
plot(f(1:N1/2),20*log10(XH(1:N1/2)/max(XH)));
title('Spectrum of x(t) using Hamming Windows');
grid;
xlabel('Frequency, Hz');
ylabel('Normalised Magnitude, [dB]');
%---------------------