Explore BrainMass
Share

Explore BrainMass

    Matlab : Lutx Function

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    I was trying to modify the matlab built-in lutx function, by using for loops, but when I tested the results with my new function it didn't give the same results.

    Please see the attached file for the fully formatted problems.

    © BrainMass Inc. brainmass.com October 9, 2019, 5:50 pm ad1c9bdddf
    https://brainmass.com/math/discrete-math/matlab-lutx-function-69585

    Attachments

    Solution Preview

    ** Please see the attached file for the complete solution **
    Thanks for using BrainMass.

    function [L,U,p] = lutx(A)
    %LU Triangular factorization
    % [L,U,p] = lutx(A) produces a unit lower triangular
    % matrix L, an upper triangular matrix U, and a
    % permutation vector p, so that L*U = A(p,:).
    [n,n] = size(A);
    p = (1:n)'
    for k = 1:n-1
    % Find largest element below diagonal in k-th column
    [r,m] = max(abs(A(k:n,k)));
    m = m+k-1;
    % Skip elimination if column is zero
    if (A(m,k) ~= 0)
    % Swap pivot row
    if (m ~= k)
    A([k m],:) = A([m k],:);
    p([k m]) = p([m k]);
    end
    % Compute multipliers
    i = k+1:n;
    A(i,k) = A(i,k)/A(k,k);
    % ...

    Solution Summary

    This solution provides a detailed step by step explanation of the given discrete math problem.

    $2.19