After using griddata, standard deviation is changed.

2 ビュー (過去 30 日間)
Han
Han 2022 年 8 月 9 日
編集済み: Jan 2022 年 8 月 13 日
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 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2022 年 8 月 10 日
@Han: You need to look at @Jan's example and have a think about what that example shows.
Jan
Jan 2022 年 8 月 10 日
編集済み: Jan 2022 年 8 月 13 日
@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));

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2022 年 8 月 9 日
編集済み: Jan 2022 年 8 月 9 日
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
  1 件のコメント
Han
Han 2022 年 8 月 10 日
Code and data updated. can you watch it again?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by