Untitled

mail@pastecode.io avatar
unknown
matlab
a year ago
300 B
5
Indexable
% multiplyMatrices.m
function result = multiplyMatrices(A, B)
    % Ensure A and B are on GPU
    A_gpu = gpuArray(A);
    B_gpu = gpuArray(B);
    
    % Multiply matrices on GPU
    result_gpu = A_gpu * B_gpu;
    
    % Gather the result back to CPU
    result = gather(result_gpu);
end