⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simul.m

📁 图像分割算法的Matlab源程序
💻 M
字号:
%  Script file: simul.m
%
%  Purpose: 
%    This program solves a system of 8 linear equations in 8
%    unknowns (a*x = b), using both full and sparse matrices.
%
%  Record of revisions:
%      Date       Programmer          Description of change
%      ====       ==========          =====================
%    10/14/98    S. J. Chapman        Original code 
%
% Define variables:
%   a            -- Coefficients of x (full matrix)
%   as           -- Coefficients of x (sparse matrix)
%   b            -- Constant coefficients (full matrix)
%   bs           -- Constant coefficients (sparse matrix)
%   x            -- Solution (full matrix)
%   xs           -- Solution (sparse matrix)

% Define coefficients of the equation a*x = b for
% the full matrix solution.
a = [  1.0  0.0  1.0  0.0  0.0  2.0  0.0 -1.0; ...
       0.0  1.0  0.0  0.4  0.0  0.0  0.0  0.0; ...
       0.5  0.0  2.0  0.0  0.0  0.0 -1.0  0.0; ...
       0.0  0.0  0.0  2.0  0.0  1.0  0.0  0.0; ...
       0.0  0.0  1.0  1.0  1.0  0.0  0.0  0.0; ...
       0.0  0.0  0.0  1.0  0.0  1.0  0.0  0.0; ...
       0.5  0.0  0.0  0.0  0.0  0.0  1.0  0.0; ...
       0.0  1.0  0.0  0.0  0.0  0.0  0.0  1.0];

b = [  3.0  2.0 -1.5  1.0 -2.0  1.0  1.0  1.0]'; 

% Define coefficients of the equation a*x = b for
% the sparse matrix solution.
as = sparse(a);
bs = sparse(b);

% Solve the system both ways
disp ('Full matrix solution:');
x = a\b

disp ('Sparse matrix solution:');
xs = as\bs

% Show workspace
disp('Workspace contents after the solutions:')
whos


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -