Interpolation of scattered earthquake data

2 次查看(过去 30 天)
Hello all, I am currently new on matlab and now i trying to write a mat lab code that can interpolate my scattered earthquake data and produce a file that contains a continuous grid of data. I have an hypoDD.reloc (double difference file). the 3rd column is Longitude (Lo), the 2nd column is Latitude (Lt) while the 4th is depth of earthquake. Please how can I go about this?. i've make a script like this :
clc;
clear all;
data = load('hypodd.reloc');
x = data(:,3);
y = data(:,2);
z = data(:,4);
[xi,yi] = meshgrid(119:1:120, -3.2:1:-2.2);
zi = griddata(x,y,z,xi,yi);
surf(xi,yi,zi);
colorbar
title('\fontsize{14}Pemodelan 3D Hiposenter Gempa Bumi Sesudah Relokasi');
legend('Sesudah Relokasi',1);
xlabel('Longitude')
ylabel('Latitude')
zlabel('Depth in Kilometers')
but, i have another issue with the depth because Zi must be a regresssion cant be matrix or vector data. please help me. T__________T
I look forward to your response.
  1 个评论
Walter Roberson
Walter Roberson 2020-10-26
Which release are you using? legend() has not permitted numeric entries for the positions for a fair number of years.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-10-26
[xi,yi] = meshgrid(119:1:120, -3.2:1:-2.2);
>> [min(x),max(x),min(y),max(y)]
ans =
119.18147 119.609587 -3.132489 -2.392441
Your query points are x = 119 and 120 exactly, and y = -3.2 and -2.2 . However, 119 is before the x data starts and 120 is after the x data ends, and -3.2 is before the y data starts and -2.2 is after the y data ends.
Therefore your four query points are all outside of the range of data stored in the data file, and therefore the griddedInterpolant returns NaN for all four points. Therefore your surf() ends up blank.
Note: in order for a surf plot to appear, somewhere in the range of data, there has to be at least a 2 x 2 sub-matrix of finite data.
  1 个评论
Afifah Shabrina
Afifah Shabrina 2020-10-28
Thank you so much for you answer, Walter! I've made new script for fix the issue and the problem is in the meshgrid and the interval data that i use before.
clc;
clear all;
data = load('hypodd.reloc');
x = data(:,3); % Long
y = data(:,2); % Lat
z = data(:,4); % Depth
A = [x y ones(length(x),1)]; % independent variable
[cc,bint,r,rint,stats]= regress(z,A); % compile the regression formula
scatter3(x,y,z); % Plot hypocenter
hold on;
x_grid=119:0.05:120;
y_grid=-3.2:0.05:-2.2;
[XFIT, YFIT]=meshgrid(x_grid, y_grid);
AFIT=cc(1)*XFIT+cc(2)*YFIT+cc(3);
surf(XFIT,YFIT,AFIT);
colorbar
title('\fontsize{14}Pemodelan 3D Hiposenter Gempa Bumi Sesudah Relokasi');
legend('Sesudah Relokasi',1);
xlabel('Longitude')
ylabel('Latitude')
zlabel('Depth in Kilometers')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Earthquake Engineering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by