Guest co-blogger: : Luis Serrano

Many students ask me how do I do this or that in MATLAB. So I thought why not have a small series of my next few blogs do that. In this blog, I show you how to solve simultaneous linear equations given in equation form.

- The MATLAB program link is here.
- The HTML version of the MATLAB program is here.
**DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR. ****DOWNLOAD THE MATLAB PROGRAM**** INSTEAD**

%% SUMMARY

% Language : Matlab 2018b;

% Authors : Autar Kaw and Luis Serrano;

% Mfile available at

% http://numericalmethods.eng.usf.edu/blog/SimultaneousEquationsEqForm.m;

% Last Revised : January 22, 2020;

% Abstract: This program shows you how to solve a set of

% simultaneous linear equations given in equation form?

% .

clc

clear all

%% INTRODUCTION

disp(‘ABSTRACT’)

disp(‘ This program shows you how to solve a’)

disp(‘ set of simultaneous linear equations given in equation form’)

disp(‘ ‘)

disp(‘AUTHOR’)

disp(‘ Autar Kaw and Luis Serrano’)

disp(‘ ‘)

disp(‘MFILE SOURCE’)

disp(‘ http://numericalmethods.eng.usf.edu/blog/SimultaneousEquationsEqForm.m’)

disp(‘ ‘)

disp(‘LAST REVISED’)

disp(‘ January 22, 2020’)

disp(‘ ‘)

%% INPUTS

% Enter the equations

syms a b c

eqn1=12*a+23*b+39*c==29

eqn2=13*a+17*b+19*c==37

eqn3=21*a+23*b+29*c==59

%% DISPLAYING INPUTS

disp(‘ ‘)

disp(‘INPUTS’)

disp(‘________________________’)

disp(‘Equations’)

disp(‘________________________’)

disp(eqn1)

disp(eqn2)

disp(eqn3)

%% THE CODE

% The solution

X=solve(eqn1,eqn2,eqn3);

% Assigning the output

a=double(X.a);

b=double(X.b);

c=double(X.c);

%% DISPLAYING OUTPUTS

disp(‘ ‘)

disp(‘OUTPUTS’)

disp(‘________________________’)

disp(‘Solution Vector’)

disp(‘________________________’)

fprintf(‘\nValue of a= %g’,a)

fprintf(‘\nValue of b= %g’,b)

fprintf(‘\nValue of c= %g’,c)

disp(‘ ‘)

disp(‘________________________’)

_______________________

This post is brought to you by

- Holistic Numerical Methods Open Course Ware:
- the textbooks on
- the Massive Open Online Course (MOOCs) available at

### Like this:

Like Loading...

## Author: Autar Kaw

Autar Kaw (http://autarkaw.com) is a Professor of Mechanical Engineering at the University of South Florida. He has been at USF since 1987, the same year in which he received his Ph. D. in Engineering Mechanics from Clemson University. He is a recipient of the 2012 U.S. Professor of the Year Award. With major funding from NSF, he is the principal and managing contributor in developing the multiple award-winning online open courseware for an undergraduate course in Numerical Methods. The OpenCourseWare (nm.MathForCollege.com) annually receives 1,000,000+ page views, 1,000,000+ views of the YouTube audiovisual lectures, and 150,000+ page views at the NumericalMethodsGuy blog. His current research interests include engineering education research methods, adaptive learning, open courseware, massive open online courses, flipped classrooms, and learning strategies. He has written four textbooks and 80 refereed technical papers, and his opinion editorials have appeared in the St. Petersburg Times and Tampa Tribune.
View all posts by Autar Kaw