0% found this document useful (0 votes)
3 views

Lecture 6

The document outlines the course SCE 2202 Computing for Chemical Engineering II at Kyambogo University, focusing on MATLAB as a programming tool for engineers. It introduces basic concepts of MATLAB, including matrix operations and function definitions. The lecture emphasizes the ease of problem-solving with MATLAB compared to other programming languages and provides examples of coding in the software.

Uploaded by

4wpc24w2gh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture 6

The document outlines the course SCE 2202 Computing for Chemical Engineering II at Kyambogo University, focusing on MATLAB as a programming tool for engineers. It introduces basic concepts of MATLAB, including matrix operations and function definitions. The lecture emphasizes the ease of problem-solving with MATLAB compared to other programming languages and provides examples of coding in the software.

Uploaded by

4wpc24w2gh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

KYAMBOGO UNIVERSITY

FACULTY OF ENGINEERING
DEPARTMENT OF MINING, CHEMICAL & PETROLEUM ENGINEERING
BACHELOR OF SCIENCE IN CHEMICAL ENGINEERING
Course Code and Name: SCE 2202 COMPUTING FOR CHEMICAL ENGINEERING II
Course Level: YR II, SEM II (2023/2024)
Course Credit: 3 CU
Lecturer: Dr. Dan Egesa
Assisting Lecturer: Joshua Ocoun (Eng.)

SCE 2202 Lecture 06 (5th March 2024)


INTRODUCTION TO MATLAB
Mat lab is a user-friendly programming language for Engineers, in the Field of Chemical
Engineering. With it, an in engineer spends more time solving a given problem and less time
programming, as is the case with other programming languages like C++, Python etc…

Its interface and use is however more sophisticated than Excel Visio basic.
Basics
With the basics we learn to feed in equations for example;
b = 2
c = 3
a = b + c
When this is fed into the interface, Matlab understands that the value of b added to the value of c
will give the value of a, and will indicate the solution.
The same applies to various other equations as we shall see further.
For matrices,
An array A of a 3by1 (m x n) matrix can be written as,
A = [ i j k ], i,j,k representing a values ( 1,2,3,4,…..).
NOTE: for any given, matrix array, do not close the bracket until you have finished using inputting
all the rows and columns e.g..
𝑖 𝑗 𝑘
𝐵 = [ 𝑙 𝑚 𝑛] = [𝑖 𝑗 𝑘; 𝑙 𝑚 𝑛; 𝑜 𝑝 𝑞](in matlab)
𝑜 𝑝 𝑞
Matlab will recognize, that it’s a matrix array. If they are two matrices, B and C, once both are
defined, matrix D = B + C can be obtained.

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
Use of “feval”, “fzero”, ”fsolve” Functions
An example is the equation y = f(x) and f(x) =𝑥 2 + 3𝑥 + 5 y can be written as;
function y = f(x)
y = x*x + 3 * x + 5
The function can then be saved in an f.m format. Matlab will store the function.
NOTE: The water following is done in the script editor. You Click on “New Script” and the script
window appears. From there you type in the equation

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.

You might also like