coefficient_matrix.m
来自「压缩包里包含了无约束优化问题常用的几种求解方法的源程序:变量轮换法(variab」· M 代码 · 共 19 行
M
19 行
function [A,b]=coefficient_matrix(str)
% File name:coefficient_matrix.m
% Author:Yan Anxin
% ID number:081810
% Date:finished on 2008.11.15
% Description:
% Here defines a function,to get the coefficient of the given function expression
% In the syntax [A,b]=coefficient_matrix(str),
% str----input,means the expression of given function
% A=coefficient_matrix(str) returns A, i.e. the coefficient of the quadratic term
% [A,b]=coefficient_matrix(str) returns b, i.e. the coefficient of the linear term
syms x1 x2 y
str=subs(str,x1*x2,y);
f=sym(str);
A=double([maple('coeff',f,x1,2),maple('coeff',f,y,1)/2;
maple('coeff',f,y,1)/2,maple('coeff',f,x2,2)]);
b=double([maple('coeff',f,x1,1);maple('coeff',f,x2,1)]);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?