gabor with no error can I plot( fr estimated with fi input )at t=1
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clear all; close all; clc
Fs=200; %sampling freq.
dt =1/Fs;
N=Fs/50 %number of samples/cycle
m=3; %no. of cycles
t =dt*(0:200); %dt*(0:m*N); %data window
fi = 50
ww=wgn(201,1,-40);
size(transpose(ww))
y=sin(2*pi*fi*t + 0.3);
x=sin(2*pi*fi*t + 0.3)+transpose(ww);
tmax=1
for j=0:200/(N*m)
t =dt*(j*m*N:(j+1)*m*N);
x=sin(2*pi*fi*t + 0.3)+transpose(wgn(1+N*m,1,-40));
%figure()
%plot(x)
n=0:1:m*N; %n=(j*m*N):1:(j+1)*m*N;
bb=0.42 - 0.5*cos(2*pi*n/(m*N+1)) + 0.08*cos(2*pi*n/(m*N+1)); %Blackman Window figure()
%figure()
%plot(bb)
u=times(x,bb);
%figure()
%plot(u)
for h=4500:5100 %4900:5100
fx(h)=0;
for k =1:1+(m*N) % since u(>(1+(m*N))=0!!!!
fx(h)=fx(h)+u(k)*exp(-2*pi*1j*h*k/(Fs*100));
end
end
ff=abs(fx);
[maxVal maxInd] = max(ff);
i=4500:5100; %4900:5100;
%figure()
%plot(i, ff(4900:5100),'red')
fr(j+1)=maxInd;
end
fr
figure(2)
plot((fr/100),'red')
hold on
RMSE = sqrt(mean(((fr/100)-fi).^2))
xlabel('time')
ylabel('frequency')
title('GABOR white noise')
plot (t,fi)
hold off
0 comentarios
Respuestas (1)
Walter Roberson
el 5 de Abr. de 2021
Editada: Walter Roberson
el 5 de Abr. de 2021
clear all; close all; clc
Fs=200; %sampling freq.
dt =1/Fs;
N=Fs/50 %number of samples/cycle
m=3; %no. of cycles
t =dt*(0:200); %dt*(0:m*N); %data window
You assign a vector of length 201 to t at this point
fi = 50
ww=wgn(201,1,-40);
size(transpose(ww))
y=sin(2*pi*fi*t + 0.3);
x=sin(2*pi*fi*t + 0.3)+transpose(ww);
tmax=1
200/(N*m)
for j=0:200/(N*m)
17 different j iterations
t =dt*(j*m*N:(j+1)*m*N);
You overwrite t with a vector of length m*N+1 = 13
x=sin(2*pi*fi*t + 0.3)+transpose(wgn(1+N*m,1,-40));
%figure()
%plot(x)
n=0:1:m*N; %n=(j*m*N):1:(j+1)*m*N;
bb=0.42 - 0.5*cos(2*pi*n/(m*N+1)) + 0.08*cos(2*pi*n/(m*N+1)); %Blackman Window figure()
%figure()
%plot(bb)
u=times(x,bb);
%figure()
%plot(u)
for h=4500:5100 %4900:5100
fx(h)=0;
for k =1:1+(m*N) % since u(>(1+(m*N))=0!!!!
fx(h)=fx(h)+u(k)*exp(-2*pi*1j*h*k/(Fs*100));
end
end
ff=abs(fx);
[maxVal maxInd] = max(ff);
i=4500:5100; %4900:5100;
%figure()
%plot(i, ff(4900:5100),'red')
fr(j+1)=maxInd;
end
So 17 different fr values
figure(2)
size(t), size(fr)
plot((fr/100),'red')
13 locations plotted, using their index as the t value
hold on
RMSE = sqrt(mean(((fr/100)-fi).^2))
xlabel('time')
ylabel('frequency')
title('GABOR white noise')
plot (t,fi, 'b*')
size(t), size(fi)
You are after the for loop. t has the same value it was last assigned:
t
Barely 1.
And fi was only ever assigned a scalar, so you are drawing with multiple different t values and a single fi value. You will get a series of dots as the result... down around time 1.
hold off
What can you do? Well, you could record the first t (or middle if you want) associated with each j iteration, so that when you
plot((fr/100),'red')
you could put in the time vector, so that at least the constant fi values would be plotted on the same time scale as the fr values.
Or maybe instead of the
plot (t,fi, 'b*')
you should instead
yline(fi)
if your purpose is to plot a reference line. Though keep in mind that your plot of fr is not plotting against absolute time...
0 comentarios
Ver también
Categorías
Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!