龙空技术网

MATLAB求解线性方程组的GUI界面

云龙派 718

前言:

眼前你们对“n元线性方程组n指的是行还是列”大概比较关心,兄弟们都想要学习一些“n元线性方程组n指的是行还是列”的相关资讯。那么小编在网摘上汇集了一些对于“n元线性方程组n指的是行还是列””的相关资讯,希望我们能喜欢,同学们一起来学习一下吧!

MATLAB线性方程组的求解及应用,非齐次线性方程组是数学方程组的一种,它符合以下的形式:

如果用线性代数中的概念来表达,则线性方程组可以写成:

Ax= b

这里的A是m×n 矩阵,x是含有n个元素列向量,b是含有m 个元素列向量。

齐次方程:AX=0

1. r(A)=未知数个数n(约束较强),该解空间只含有零向量。

2.r(A)<未知数个数n(约束不够),由齐次线性方程组解空间维数 = n - r(A) >0,所以该齐次线性方程组有非零解,而且不唯一,存在一个基础解系(基础解系中的向量个数为 n - r(A)个)。

非齐次方程:AX=B

(1)R(A)< r(A|B),方程组无解 。

(2)r(A)=r(A|B)=n,方程组有唯一解 。

(3)r(A)=r(A|B) < n,方程组有无穷解 。

(4)r(A)>r(A|B),这种情况不存在 。

其中r()代表矩阵的秩,A|B是增广矩阵,n是X未知数个数。

1.MATLAB求解线性方程组的GUI界面

Step1:输入齐次方程组Ax=0的系数矩阵A。

Step2:点击计算齐次按键,判断方程组求解结果情况,有解时计算出基础解系。

Step3:输入非齐次方程组Ax=b的系数矩阵A和增广矩阵b。

Step4:点击计算非齐次按键,判断方程组求解结果情况,有解时计算出基础解系和特解,有唯一解时求出对应的唯一解。

Step5:点击清除按键,清除输入。

Step6: 点击关闭。

2.程序

下面呈现主要程序,需要完整程序的可以赞赏20元及以上,进行联系,或者发截图到微信公众号云龙派对话窗口或者直接在公众号里,点击“联系掌门”按键,编程不易,还请见谅。

function varargout = jisuanfangchengzu(varargin)% JISUANFANGCHENGZU MATLAB code for jisuanfangchengzu.fig%      JISUANFANGCHENGZU, by itself, creates a new JISUANFANGCHENGZU or raises the existing%      singleton*.%%      H = JISUANFANGCHENGZU returns the handle to a new JISUANFANGCHENGZU or the handle to%      the existing singleton*.%%      JISUANFANGCHENGZU('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in JISUANFANGCHENGZU.M with the given input arguments.%%      JISUANFANGCHENGZU('Property','Value',...) creates a new JISUANFANGCHENGZU or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before jisuanfangchengzu_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to jisuanfangchengzu_OpeningFcn via varargin.%%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one%      instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLE% Edit the above text to modify the response to help jisuanfangchengzu% Last Modified by GUIDE v2.5 21-Apr-2022 22:22:52% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @jisuanfangchengzu_OpeningFcn, ...                   'gui_OutputFcn',  @jisuanfangchengzu_OutputFcn, ...                   'gui_LayoutFcn',  [] , ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})    gui_State.gui_Callback = str2func(varargin{1});endif 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 jisuanfangchengzu is made visible.function jisuanfangchengzu_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 jisuanfangchengzu (see VARARGIN)% Choose default command line output for jisuanfangchengzuhandles.output = hObject;movegui(gcf,'center');% Update handles structureguidata(hObject, handles);% UIWAIT makes jisuanfangchengzu wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = jisuanfangchengzu_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 structurevarargout{1} = handles.output;function edit2_Callback(hObject, eventdata, handles)% hObject    handle to edit2 (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 edit2 as text%        str2double(get(hObject,'String')) returns contents of edit2 as a double% --- Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction edit3_Callback(hObject, eventdata, handles)% hObject    handle to edit3 (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 edit3 as text%        str2double(get(hObject,'String')) returns contents of edit3 as a double% --- Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction 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%        str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- 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'));Rank_A=rank(A);    [m,n]=size(A);   if(Rank_A<n)       %秩小于未知量的个数,方程组有无穷解       %计算基础解系1       set(handles.edit2,'string',"方程组有无穷解!")       z=null(A,'r');       set(handles.edit3,'string',num2str(z))   elseif(Rank_A==n)       set(handles.edit2,'string',"方程组只有零解!")       z=repmat(0,n,1);        set(handles.edit3,'string',num2str(z))   end

3.参考内容

[1] CSDN博主MicroSmiles的文章《线性方程组求解》,文章链接:

[2] 百度词条.

本文内容来源于网络,仅供参考学习,如内容、图片有任何版权问题,请联系处理,24小时内删除。

作 者 | 郭志龙

编 辑 | 郭志龙

校 对 | 郭志龙

标签: #n元线性方程组n指的是行还是列