fig = uifigure('Position', [100, 100, 800, 600]);
    gl = uigridlayout(fig, [2, 1]);
    title(axMain, 'Main Image');
    title(axZoom, 'Zoomed In');
    img = imread('peacock.jpg'); 
    imshow(img, 'Parent', axMain);
    fig.UserData = struct('img', img, 'axMain', axMain, 'axZoom', axZoom);
    fig.WindowButtonMotionFcn = @(src, event) updateZoom(src);
    cursorPoint = axMain.CurrentPoint(1, 1:2); 
    if cursorPoint(1) >= xLimits(1) && cursorPoint(1) <= xLimits(2) && ...
       cursorPoint(2) >= yLimits(1) && cursorPoint(2) <= yLimits(2)
        x = round(cursorPoint(1));
        y = round(cursorPoint(2));
        xMin = max(1, x - zoomSize);
        xMax = min(w, x + zoomSize);
        yMin = max(1, y - zoomSize);
        yMax = min(h, y + zoomSize);
        zoomedRegion = img(yMin:yMax, xMin:xMax, :);
        imshow(zoomedRegion, 'Parent', axZoom);