RMS error and Mean absolute error from text files
Mostrar comentarios más antiguos
There are 24 text files name from interpot_linear_00.txt to interpot_linear_24.txt in a folder. Each file consist on three columns( First is latitude, second is longitude and third column is temperature). I want to check best of my interpolation technique for 324 samples of temperature.
That why i randomly select 30% of samples and gives them -9999.0. Now using scatter data interpolation i consider -9999.0 as bad data values and based upon my 70% remaining samples interpolate -9999.0. After interpolating values of -9999.0 i cross check its value with its original one and calculate overall R.M.S error and Absolute mean error for each text file.
Here i am just try, but little task to remains which need assistance as in my comments
methods = {'natural'};
S = dir('interpot_linear_*.txt');
N = sort({S.name});
for K = 1 : length(N)
infile = N{K};
whichfile = sscanf(infile, 'interpot_linear_%c%c');
% Load the data
data = load(infile);
% separate the data columns, just to make the code clear
Lat = data(:,1); % Column 1 is Latitude
Lon = data(:,2); % Column 2 is Longitude
Tmp = data(:,3); % Column 3 is Temperature
% Creating 30% of sample as -9999.0
nr=round(n*0.3);
TE=Tmp(randperm(n,nr));
good_temp = find(TE);
TE(:)=-9999.000;
%makes another temperature column (say Tmp1) with same indices of randomly
%seclected but -9999.0 value.
% Find the "good" data points. It should be 70% of remaing samples?
good_temp = find(Tmp > -9999.000);
% find the "bad" data points
bad_temp = find(Tmp == -9999.000);
for midx = 1 :length(methods)
method = methods{midx};
outfile = ['interpot_' method '_' whichfile '.txt'];
% creating vector
T = scatteredInterpolant(Lat(good_temp), Lon(good_temp), Tmp(good_temp), method);
% use the interpolation object to interpolate temperature values
interp_values = T(Lat(bad_temp), Lon(bad_temp));
% replace the bad values with the interpolated values
Tmp(bad_temp) = interp_values;
% Here i will calculate RMS error with formula for each file
RMS=sqrt(mean(Tmp(:).^2 - Tmp_new(:).^2));
%Here i am calculating Mean Absolute Error for each file with formula
MAE=sum(abs(Tmp(:)-Tmp_new(:)))/n;
% Here i will export results in a excel file.
end
end %files
After calculating RMS error and AM error for 24 text file. I want summery statistics in excel file( File no, RMS, AME etc.) My some text files has been attached with this post.
Please help!
1 comentario
The code in the question is derived from these answers (questions also from same OP)
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 1 de Abr. de 2016
1 voto
I have glanced at your question and I see that Duane is handling it perfectly well. You do not need me for it.
3 comentarios
Muhammad Usman Saleem
el 1 de Abr. de 2016
Walter Roberson
el 1 de Abr. de 2016
I did, several hours before.
Muhammad Usman Saleem
el 1 de Abr. de 2016
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!