function varargout = main(varargin)
% MAIN MATLAB code for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help main
% Last Modified by GUIDE v2.5 10-May-2020 22:49:48
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before main is made visible.
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% 逆矩阵
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x1=inv(A)*b;
R = num2str(x1);
set(handles.edit3,'String',R,'max',8);
handles.x1=x1;
guidata(hObject, handles);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% 三角形法
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x4=sanjiao(A,b,n)';
R = num2str(x4);
wucha=mean(x4-handles.x1);wucha=roundn(wucha,-4);
set(handles.edit3,'String',R,'max',8);
set(handles.edit4,'String',['三角方程组解法平均误差=',num2str(wucha)],'max',8);
handles.x4=x4;
guidata(hObject, handles);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% 高斯消元法
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x2=guass(n,A,b)
R = num2str(x2);
wucha=mean(x2-handles.x1);wucha=roundn(wucha,-4);
set(handles.edit3,'String',R,'max',8);
set(handles.edit4,'String',['高斯消元法平均误差=',num2str(wucha)],'max',8);
handles.x2=x2;
guidata(hObject, handles);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% 列消元
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x5=Lie_Gauss(A,b,n);
R = num2str(x5);
wucha=mean(x5-handles.x1);wucha=roundn(wucha,-4);
set(handles.edit3,'String',R,'max',8);
set(handles.edit4,'String',['列主元消元法平均误差=',num2str(wucha)],'max',8);
handles.x5=x5;
guidata(hObject, handles);
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% LU分解
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x3=Lu_Decomplete(n,A,b)
R = num2str(x3);
wucha=mean(x3-handles.x1);wucha=roundn(wucha,-4);
set(handles.edit3,'String',R,'max',8);
set(handles.edit4,'String',['LU分解平均误差=',num2str(wucha)],'max',8);
handles.x3=x3;
guidata(hObject, handles);
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% 雅可比矩阵
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x6=jacobi(A,b,n)
R = num2str(x6);
wucha=mean(x6-handles.x1);wucha=roundn(wucha,-4);
set(handles.edit3,'String',R,'max',8);
set(handles.edit4,'String',['雅可比迭代平均误差=',num2str(wucha)],'max',8);
handles.x6=x6;
guidata(hObject, handles);
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% disp('高斯-塞德尔迭代')
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x7=Gauss_Seidel(A,b,n);
R = num2str(x7);
wucha=mean(x7-handles.x1);wucha=roundn(wucha,-4);
set(handles.edit3,'String',R,'max',8);
set(handles.edit4,'String',['高斯-塞德尔迭代平均误差=',num2str(wucha)],'max',8);
handles.x7=x7;
guidata(hObject, handles);
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% disp('超松弛迭代')
A = str2num((get(handles.edit1,'String')));
b = str2num((get(handles.edit2,'String')));
n=length(b);
x8 = LinearEquations_SSOR(A, b,n);
R = num2str(x8);
wucha=mean(x8-handles.x1);
wucha=roundn(wucha,-4);
set(handles.edit3,'String',R,'max',8);
set(handles.edit4,'String',['超松弛迭代平均误差=',num2str(wucha)],'max',8);
handles.x8=x8;
guidata(hObject, handles);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% st
Matlab 实现高斯消元LU分解.zip
版权申诉
188 浏览量
2021-12-26
12:56:38
上传
评论
收藏 74KB ZIP 举报
天天Matlab科研工作室
- 粉丝: 2w+
- 资源: 7251
最新资源
- yolo目标检测项目实验
- downloadFile-1.hc
- Centos7.9环境下离线安装开源版Nginx(亲测版)
- C++课程设计:基于Qt的航班信息管理系统
- ADS7822UVerilog驱动,前面传的有点问题
- 基于python的高性能爬虫程序,使用了多线程+缓存+xpath实现的,这里以彼-岸图库为例,实现,仅用于学习交流
- 中分辨率成像光谱仪(MODIS)烧毁面积产品信息MODIS-C6-BA-User-Guide-1.2.pdf
- Screenshot_20240427_172613_com.huawei.browser.jpg
- 关于学习Python的相关资源网站链接及相关介绍.docx
- (HAL库)基于STM32F103C8T6的温控PID系统[Dht11、ESP8266、无线透传、L298N……]
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈