# Need help to correct and modify MATLAB code

9 ビュー (過去 30 日間)
Moustafa Abedel Fattah 2024 年 5 月 9 日
コメント済み: Walter Roberson 2024 年 5 月 9 日
I have the following code :
%===============================%
clc
close all;
clear;
% Define the given arrays
x = [0.02 0.55 1.00 1.4 1.4 2.32 2.62 ...
3.77 4.81 5.61 6.29 6.29 6.00 ...
6.00 7.00 7.00 7.00];
z = [5 5 5 5 5 4 4 4 4 4 4 4 2 2 2 2 2];
% Find sudden changes in depth
sudden_changes = diff(z);
% Find indices where sudden changes occur
fault_indices = find(sudden_changes ~= 0) + 1;
% Plot the top of the rock formation
plot(x, z, '-o');
hold on;
% Plot fault lines
for i = 1:length(fault_indices)
idx = fault_indices(i);
plot([x(idx-1), x(idx)], [z(idx-1), z(idx)], 'r--');
end
% Calculate dip angle using the tan-rule
dip_angles = atand(diff(z) ./ diff(x));
% Identify normal and reverse faults
normal_faults = dip_angles <= 90;
reverse_faults = dip_angles > 90;
% Plot normal faults
scatter(x(fault_indices(normal_faults)), z(fault_indices(normal_faults)), 'g', 'filled');
The logical indices contain a true value outside of the array bounds.
% Plot reverse faults
scatter(x(fault_indices(reverse_faults)), z(fault_indices(reverse_faults)), 'm', 'filled');
xlabel('X-axis');
ylabel('Depth');
title('Top of the rock formation with fault lines');
legend('Top of the rock formation', 'Fault lines', 'Normal faults', 'Reverse faults');
set(gca, 'YDir', 'reverse');
grid on;
%===============================%
I need to draw the Earth's surface where the depth is constan surface and equal to zero
and need th extend the the fault lines to the Earths surface as shown in attached figure
and need to detect the type of fault from intersected fault line with Earth's surface
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Walter Roberson 2024 年 5 月 9 日
fault_indices = find(sudden_changes ~= 0) + 1;
That is variable length, only the locations where sudden_changes is non-zero
dip_angles = atand(diff(z) ./ diff(x));
That is one element shorter than z (or x)
normal_faults = dip_angles <= 90;
Same length as dip_angles, so one element shorter than z (or x)
scatter(x(fault_indices(normal_faults)), z(fault_indices(normal_faults)), 'g', 'filled');
fault_indices is short, normal_faults is full length, fault_indices indexed at normal_faults is a problem.

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

R2014b

### Community Treasure Hunt

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

Start Hunting!

Translated by