Matlab GUI 井眼图绘制:输入参数,填充地层颜色
以下是一个简单的实现:
function wellLogGUI()
% 创建GUI窗口
fig = figure('Position', [100, 100, 800, 600], 'MenuBar', 'none', 'NumberTitle', 'off', 'Name', 'Well Log');
% 创建输入框和标签
uicontrol('Style', 'text', 'String', 'X Size:', 'Position', [20, 550, 50, 20]);
xSizeEdit = uicontrol('Style', 'edit', 'Position', [70, 550, 50, 20]);
uicontrol('Style', 'text', 'String', 'Y Size:', 'Position', [20, 520, 50, 20]);
ySizeEdit = uicontrol('Style', 'edit', 'Position', [70, 520, 50, 20]);
uicontrol('Style', 'text', 'String', 'Well Radius:', 'Position', [20, 490, 80, 20]);
wellRadiusEdit = uicontrol('Style', 'edit', 'Position', [100, 490, 50, 20]);
uicontrol('Style', 'text', 'String', 'Layer 2 Top:', 'Position', [20, 460, 80, 20]);
layer2TopEdit = uicontrol('Style', 'edit', 'Position', [100, 460, 50, 20]);
uicontrol('Style', 'text', 'String', 'Layer 2 Bottom:', 'Position', [20, 430, 80, 20]);
layer2BottomEdit = uicontrol('Style', 'edit', 'Position', [100, 430, 50, 20]);
% 创建绘图按钮
plotButton = uicontrol('Style', 'pushbutton', 'String', 'Plot', 'Position', [20, 380, 80, 30], 'Callback', @plotButtonCallback);
% 绘图函数
function plotButtonCallback(~, ~)
% 获取输入值
xSize = str2double(get(xSizeEdit, 'String'));
ySize = str2double(get(ySizeEdit, 'String'));
wellRadius = str2double(get(wellRadiusEdit, 'String'));
layer2Top = str2double(get(layer2TopEdit, 'String'));
layer2Bottom = str2double(get(layer2BottomEdit, 'String'));
% 创建绘图区域
ax = axes('Parent', fig, 'Position', [0.2, 0.1, 0.7, 0.8]);
% 绘制井眼
theta = linspace(0, 2*pi, 100);
x = wellRadius * cos(theta);
y = wellRadius * sin(theta);
patch(ax, x, y, [1, 1, 1]);
% 绘制地层
y1 = 0;
y2 = layer2Top;
y3 = layer2Bottom;
y4 = -ySize;
x1 = -xSize/2;
x2 = xSize/2;
patch(ax, [x1, x2, x2, x1], [y1, y1, y2, y2], [0.5, 0.5, 0.5]);
patch(ax, [x1, x2, x2, x1], [y2, y2, y3, y3], [0.8, 0.8, 0]);
patch(ax, [x1, x2, x2, x1], [y3, y3, y4, y4], [0.5, 0.5, 0.5]);
% 设置坐标轴范围和标签
xlim(ax, [-xSize/2, xSize/2]);
ylim(ax, [-ySize, 0]);
xlabel(ax, 'X');
ylabel(ax, 'Depth');
end
end
在命令行中运行 wellLogGUI 函数即可打开GUI界面。输入各个参数后,点击 Plot 按钮即可绘制井图。效果如下图所示:

原文地址: https://www.cveoy.top/t/topic/nZBl 著作权归作者所有。请勿转载和采集!