Matlab - ajuste para graficar un espectro

 
Vista:
sin imagen de perfil

ajuste para graficar un espectro

Publicado por ADy (3 intervenciones) el 23/09/2007 05:32:36
hola, buena noche!

espero que esten bien, escribo para ver si alguien me puede ayudar como ponerle un ajuste a mi grafica por que los resultados que me arroja no salen muy claros y necesito que sea algo mas definido. A continuacion ingreso el codigo. Espero que me puedan ayudar, de antemano GRACIAS:


load compiduv.vec -ascii;

vel=compiduv(1:end,1);
dir=compiduv(1:end,2);
u=compiduv(1:end,3);
v=compiduv(1:end,4);

x= 0:1:12
t=linspace(0,12,8784);

subplot(3,1,1);
plot(t,u,'b');
grid on;
set (gca,'XTickLabel',{'ene';'mar';'may';'jul';'sep';'nov'});
set(gca,'XColor','red','YColor','red');
xlabel('Año 2000 (días)');
ylabel('Este-Oeste (m/seg)');
text(4.1,15,'Componente U','FontSize',10,'Color','b');

set (gca,'TickDir','out');

% axis off; %para que no ponga los ejes


subplot(3,1,3);
plot(t,v,'r');
hold on;
grid on;
set (gca,'XTickLabel',{'ene';'mar';'may';'jul';'sep';'nov'});
set(gca,'XColor','blue','YColor','blue');
xlabel('Año 2000 (días)');
ylabel('Norte-Sur (m/seg)');
text(4.1,25,'Componente V','FontSize',10,'Color','r');
set (gca,'TickDir','out');


%axis off; %p

LO QUE BUSCO QUE ESAS DOS GRAFICAS SALGAN CON SUS DATOS MAS DEFINIDOS, QUISE UTILIZAR LA FUNCION fft PERO NO SUPE COMO APLICARLA, HABER SI ALGUIEN ME PUEDE ORIENTAR. GRACIAS.

SALU2 ADY
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:ajuste para graficar un espectro

Publicado por fismat (391 intervenciones) el 24/09/2007 15:56:33
Hola Ady

A continuacion te envio un ejemplo que figura en la ayuda de Matlab sobre el uso de la funcion fft.

Examples

A common use of Fourier transforms is to find the frequency components of a signal buried in a noisy time domain signal. Consider data sampled at 1000 Hz. Form a signal containing a 50 Hz sinusoid of amplitude 0.7 and 120 Hz sinusoid of amplitude 1 and corrupt it with some zero-mean random noise:

Fs = 1000; % Sampling frequency
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t)); % Sinusoids plus noise
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)')

It is difficult to identify the frequency components by looking at the original signal. Converting to the frequency domain, the discrete Fourier transform of the noisy signal y is found by taking the fast Fourier transform (FFT):

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);

% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

Saludos,
Fismat

PD: espero sea de ayuda.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:ajuste para graficar un espectro

Publicado por fismat (391 intervenciones) el 24/09/2007 15:56:45
Hola Ady

A continuacion te envio un ejemplo que figura en la ayuda de Matlab sobre el uso de la funcion fft.

Examples

A common use of Fourier transforms is to find the frequency components of a signal buried in a noisy time domain signal. Consider data sampled at 1000 Hz. Form a signal containing a 50 Hz sinusoid of amplitude 0.7 and 120 Hz sinusoid of amplitude 1 and corrupt it with some zero-mean random noise:

Fs = 1000; % Sampling frequency
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t)); % Sinusoids plus noise
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)')

It is difficult to identify the frequency components by looking at the original signal. Converting to the frequency domain, the discrete Fourier transform of the noisy signal y is found by taking the fast Fourier transform (FFT):

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);

% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

Saludos,
Fismat

PD: espero sea de ayuda.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

RE:ajuste para graficar un espectro

Publicado por Ady (3 intervenciones) el 25/09/2007 02:47:27
Hola gracias por el ejemplo, ya lo cheque pero no logro suavizar el ruido de mi grafica, nose si me podrias explicar mas detalladamente como hacerlo. de antemano te agradezco tu atencion.

load compiduv.vec -ascii;

vel=compiduv(1:end,1);
dir=compiduv(1:end,2);
u=compiduv(1:end,3);
v=compiduv(1:end,4);

x=0:1:12
t=linspace(0,12,8784);
subplot(3,1,1);
plot(t,u,'b');
grid on;
set (gca,'XTickLabel',,{'ene';'feb';'mar';'abr';'may';'jun';'jul';'ago';'sep'; 'oct'; 'nov';'dic'});
set(gca,'XColor','red','YColor','red');

xlabel('Año 2000 (días)');
ylabel('Este-Oeste (m/seg)');
text(4.1,15,'Componente U','FontSize',10,'Color','b');

set (gca,'TickDir','out');

subplot(3,1,2);
plot(t,v,'r');
grid on;
set (gca,'XTickLabel',{'ene';'mar';'may';'jul';'sep';'nov'});
set(gca,'XColor','blue','YColor','blue');
xlabel('Año 2000 (días)');
ylabel('Norte-Sur (m/seg)');
text(4.1,25,'Componente V','FontSize',10,'Color','r');
set (gca,'TickDir','out');

subplot(3,1,3);
plot(t,u,'b');
hold on;
grid on;
plot(t,v,'r');
ylim([-30 30]);

set (gca,'XTickLabel',{'ene';'mar';'may';'jul';'sep';'nov'});
set(gca,'XColor','black','YColor','black');
xlabel('Año 2000 (días)');
ylabel('Componente (U)y(V) (m/seg)');
text(4.1,25,'Componente U','FontSize',10,'Color','b');
text(8.1,25,'Componente V','FontSize',10,'Color','r');

set (gca,'TickDir','out');

OTRAS DE LAS COSAS QUE NO HE PODIDO REALIZAR ES QUE CUANDO PONGO QUE EN LOS EJES APAREZCA LOS MESES DEL AÑO NO ME APARECEN TODOS POR ELLO EN LA GRAFICA 2 Y 3 PUSE SOLO
set (gca,'XTickLabel',{'ene';'mar';'may';'jul';'sep';'nov'});
SIN EMBARGO QUIERO QUE APAREZCA TODO LOS MESES COMO PUSE EN LA GRAFICA 1
set (gca,'XTickLabel',,{'ene';'feb';'mar';'abr';'may';'jun';'jul';'ago';'sep'; 'oct'; 'nov';'dic'});
Y ALA HORA DE QUE SALE LA GRAFICA SOLO APARECE DE ENERO A JULIO.

SI ME PUEDEN AYUDAR LES AGRADEZCO.
BUENA NOCHE!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:ajuste para graficar un espectro

Publicado por fismat (391 intervenciones) el 25/09/2007 12:27:25
Hola Ady

Podrias enviarme tus datos a mi email para ver si encuentro una solucion.

Saludos
Fismat

PD: load compiduv.vec -ascii;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:ajuste para graficar un espectro

Publicado por fismat (391 intervenciones) el 25/09/2007 15:55:13
Hola ADy

He resuelto el problema de los ejes.
te envio el nuevo codigo

load compiduv.vec

vel=compiduv(1:end,1);
dir=compiduv(1:end,2);
u=compiduv(1:end,3);
v=compiduv(1:end,4);

t=linspace(datenum('01-jan-2000'),datenum('31-dec-2000'),length(u));
subplot(3,1,1)
plot(t,u,'b')
datetick('x',3)
grid on
set (gca,'XTickLabel',{'ene';'feb';'mar';'abr';'may';'jun';'jul';'ago';'sep';'oct'; 'nov';'dic'});
ylabel('Este-Oeste [m.s^{-1}]');

subplot(3,1,2);
plot(t,v,'r');
grid on;
datetick('x',3)
set (gca,'XTickLabel',{'ene';'feb';'mar';'abr';'may';'jun';'jul';'ago';'sep';'oct'; 'nov';'dic'});
ylabel('Norte-Sur [m.s^{-1}]');

subplot(3,1,3)
plot(t,u,'b',t,v,'r');
grid on;
datetick('x',3)
set (gca,'XTickLabel',{'ene';'feb';'mar';'abr';'may';'jun';'jul';'ago';'sep';'oct'; 'nov';'dic'});
ylabel('Componente U , V [m.s^{-1}]')
xlabel('Eje de tiempo 2000 [Dias]')

Respecto al suavizado no tengo tanta experiencia, quizas podrias usar el toolbox de ajuste de curvas cftool, puedes ver en la ayuda de matlab

Saludos
Fismat
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

RE:ajuste para graficar un espectro

Publicado por Ady (3 intervenciones) el 25/09/2007 16:41:07
Hola Fismat !

DE antemano te agradezco que me hayas ayudado a solucionar el problema de los ejes, en cuanto al ajuste checare lo que me dices. De antemano muchas GRACIAS!

que tengas un lindo dia!

Adriana R.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:ajuste para graficar un espectro

Publicado por fismat (391 intervenciones) el 25/09/2007 17:51:17
Hola Adriana

Trata de ver el toolbox de ajustes de curvas cftool, es muy bueno.
Que tengas un buen dia tambien.

Saludos
David C.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:ajuste para graficar un espectro

Publicado por Antonio (15 intervenciones) el 30/09/2007 18:29:08
Hola Ady

Lograste usar el cftool para el suviazado de la signal
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar