📄 utriangsl.m
字号:
function [b,iflag] = utriangsl( A, b);%% UTRIANGSL solves an N by N linear system with% upper triangular matrix.%% Usage% [b,iflag] = utriangsl( A, b)%% input:% A: the upper triangular N by N matrix A%% b: the right hand side b. b can have more than one column. % In this case a system with multiple right hand sides is% solved.%%% output:% b: the solution of the system A x = b, if iflag = 0%% iflag: error flag% iflag = 0 solution could be computed and is% stored in b% iflag = 1 dimension of A or of b is not correct% iflag > 1 zero diagonal element detected in row iflag+1%%iflag = 0;% get size of A and check dimensions[m,n] = size(A);if ( m ~= n | n ~= size(b,1) ) iflag = 1; returnend% Start back substitution (column form)for i = n:-1:1 if( A(i,i) == 0 ) iflag = i+1; return end b(i,:) = b(i,:) / A(i,i); b(1:i-1,:) = b(1:i-1,:) - A(1:i-1,i) * b(i,:);end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -