MATLAB中求矩阵非零元的坐标: 方法1: index=find(a); [i,j]=ind2sub(size(a),index); disp([i,j]) 方法2: [i,j]=find(a>0|a<0) %列出所有非零元的坐标 [i,j]=find(a==k) %找出等于k值的矩阵元素的坐标 所用函数简介: IND2SUB Multiple subscripts from linear index. IND2SUB is used to determine the equivalent
+二分法求平方根 x = float(raw_input('Enter the number')) low = 0 high = x guess = (low + high ) / 2 if x < 0: print 'Number Error' while abs(guess**2 - x) > 1e-5: if guess**2 < x: low = guess else: high = guess guess = (low + high) / 2 print 'The root o
用二分法求在(a,b)上单调的函数近似值 第八行的表达式可更改,第三行的kexi决定的精度,小数值计算可将第五行的extended更为real或double PROGRAM EQUANTION (input,output); CONST kexi=0.0000001; VAR a,b,c:extended; FUNCTION fx(x:extended):extended; BEGIN fx:=ln(x)/ln(2); END; BEGIN writeln('Please input a a
function qiuni =INV_GET(a)N=length(a);M=eye(N);%得到上三角矩?for i=1:N max=a(i,i); A=i; for j=i+1:N if(abs(a(j,i))>abs(max))%找最大值 max=a(j,i); A=j; end end for m=1:N temp1=a(i,m);%交换最大值值所在的行和当前行 a(i,m)=a(A,m); a(A,m)=temp1; temp2=M(i,m); M(i,m)=M(A,m); M(A,