Azzera filtri
Azzera filtri

Interpolation of scattered earthquake data

2 visualizzazioni (ultimi 30 giorni)
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 Commento
Walter Roberson
Walter Roberson il 26 Ott 2020
Which release are you using? legend() has not permitted numeric entries for the positions for a fair number of years.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 26 Ott 2020
[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 Commento
Afifah Shabrina
Afifah Shabrina il 28 Ott 2020
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')

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Earthquake Engineering in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by