After using griddata, standard deviation is changed.

3 visualizaciones (últimos 30 días)
Han
Han el 9 de Ag. de 2022
Editada: Jan el 13 de Ag. de 2022
I rewritten it with the code and data. Thank you.
Hello. Respected seniors.
I'm not familiar with English, so I'm using a translator, so please forgive me if the sentences are weird.
New data was created using grid data for use in other programs.
The maximum and minimum values of the data were made within the expected or acceptable margin of error, but the standard deviation was greatly reduced to create unacceptable figures.
This is the code used.
clear,close all;
Fin=fopen('data1.csv','rt');
if(Fin==-1)
errordlg('File Open Error ! Program stoped!','Error');
error('File Open Error ! Program stoped!');
end
State=0;
radius = 300;
while(~State)
npoints = 2839 ;
A=fscanf(Fin,'%e ',[8,npoints]);
Nx=A(2,:);
Ny=A(3,:);
Nz=A(7,:);
Nx7=Nx ;
Ny7=Ny ;
Nz7=Nz ;
State=feof(Fin);
end
%% make_int
deltaZ = max(Nz) - min(Nz);
X_int = -255:0.9961:255 ;
Y_int = -255:0.9961:255 ;
Y2_int = flip(Y_int);
[xq_int,yq_int] = meshgrid(X_int,Y2_int);
gd_int = griddata(Nx7,Ny7,Nz7,xq_int,yq_int);
gd_int1 = gd_int*(10^5);
gd_int2 = gd_int1;
gd_int3 = round(gd_int2);
gridsize = 512;
for i = 1:gridsize
for j = 1:gridsize
if isnan(gd_int3(i,j))
gd_int4(i,j) = -32767;
else
gd_int4(i,j) = gd_int3(i,j);
end
end
end
M = gd_int4;
dlmwrite('L1_front_gx_codierite_grid512_ssz0.1.int', M , 'delimiter' , ' ' , 'precision' , '%d');
%%
for i = 1:gridsize
for j = 1:gridsize
if isnan(gd_int3(i,j))
gd5(i,j) = 0;
else
gd5(i,j) = gd_int3(i,j);
end
end
end
AB2 = nonzeros(gd5);
%%
for i = 1:gridsize
for j = 1:gridsize
if isnan(gd_int(i,j))
gd6(i,j) = 0;
else
gd6(i,j) = gd_int(i,j);
end
end
end
AB = nonzeros(gd6);
%%
%%figure
%%mesh(xq_int,yq_int,gd_int);
%%hold on
%%plot3(Nx,Ny,Nz,'o');
%%h = gca;
%%h.XLim = [-255 255];
%%h.YLim = [-255 255];
%%colormap('jet')
figure
mesh(xq_int,yq_int,gd_int);
h = gca;
h.XLim = [-255 255];
h.YLim = [-255 255];
colormap('jet')
%%figure
%%surface(xq_int,yq_int,gd_int);
%%h = gca;
%%h.XLim = [-255 255];
%%h.YLim = [-255 255];
%%colormap('jet')
%%
fclose(Fin);
This is a result from code. red box is calculated standard deviation value.
It is the rms value calculated by another code. change the unit, it's 486.7774.
The difference between the two values is fifty.
Can I know if the standard deviation value decreases using the grid data?
  6 comentarios
Bjorn Gustavsson
Bjorn Gustavsson el 10 de Ag. de 2022
@Han: You need to look at @Jan's example and have a think about what that example shows.
Jan
Jan el 10 de Ag. de 2022
Editada: Jan el 13 de Ag. de 2022
@Han: Just a note, you can simplify:
gd_int = griddata(Nx7,Ny7,Nz7,xq_int,yq_int);
gd_int1 = gd_int*(10^5);
gd_int2 = gd_int1;
gd_int3 = round(gd_int2);
gridsize = 512;
for i = 1:gridsize
for j = 1:gridsize
if isnan(gd_int3(i,j))
gd_int4(i,j) = -32767;
else
gd_int4(i,j) = gd_int3(i,j);
end
end
end
M = gd_int4;
for i = 1:gridsize
for j = 1:gridsize
if isnan(gd_int3(i,j))
gd5(i,j) = 0;
else
gd5(i,j) = gd_int3(i,j);
end
end
end
AB2 = nonzeros(gd5);
for i = 1:gridsize
for j = 1:gridsize
if isnan(gd_int(i,j))
gd6(i,j) = 0;
else
gd6(i,j) = gd_int(i,j);
end
end
end
AB = nonzeros(gd6);
to:
A = griddata(Nx7, Ny7, Nz7, xq_int, yq_int);
B = round(A * 1e5);
M = fillmissing(B, 'constant', -32767);
AB2 = nonzeros(fillmissing(B, 'constant', 0));
AB = nonzeros(fillmissing(A, 'constant', 0));

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 9 de Ag. de 2022
Editada: Jan el 9 de Ag. de 2022
Of course increasing the number of points by an interpolation reduces the standard deviation:
std([1,100])
ans = 70.0036
std(interp1([1, 2], [1, 100], linspace(1, 2, 100)))
ans = 29.0115
std(1:100) % Which is the same except for rounding effects
ans = 29.0115

Categorías

Más información sobre Ordinary 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!

Translated by