Error using plot Vectors must be the same length. Error in rain_analysis (line 15) plot(t/T,yt,'-b');
Mostra commenti meno recenti
clear all;
close all;
T = 30*24*60*60; % Sampling interval
LT = 360; % Number of sampling
t = (0:LT-1)*T; % Sampling time
%Read data
fid=fopen('caps.dat','rb');
yt=fread(fid,'float32');
fclose(fid);
yt(361) = [];
figure;
plot(t/T,yt,'-b');
grid on;
set(gca,'xlim',[0 max(t/T)]);
xlabel('Time (month)','fontweight','bold');
ylabel('Rainfall (mm)','fontweight','bold');
title('GPCC Rainfall Data in West Java','fontsize',14);
%Fourier transform
F = 1/T; % Maximum sampling frequency
f = F*linspace(0,1,LT); % All sampling frequency
Y = fft(yt)/LT;
Yf = abs(Y);
% All frequency plot
figure;
plot(f,Yf,'-r');
xlabel('Frequency (Hz)','fontweight','bold');
ylabel('Amplitude','fontweight','bold');
title('GPCC Rainfall All Amplitude Spectrum Plot','fontsize',14);
set(gca,'xlim',[0 max(f)]);
grid on;
% True half-frequency plot
NF = F/2; % Nyquist frequency
figure;
plot(f(1:LT/2+1),Yf(1:LT/2+1),'-r');
xlabel('Frequency (Hz)','fontweight','bold');
ylabel('Amplitude','fontweight','bold');
title('GPCC Rainfall One Side Amplitude Spectrum Plot','fontsize',14);
set(gca,'xlim',[0 f(LT/2+1)]);
grid on;
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Array Geometries and Analysis in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!