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

Week 1 Part 1 Fundamentals

The document introduces programming concepts using MATLAB, emphasizing its importance in problem-solving and engineering. It outlines the four essential steps in program design: specification, algorithm design, coding, and execution, illustrated with an example of calculating the volume of a cone. Additionally, it mentions the use of MATLAB Online and provides a link to a live script for further learning.

Uploaded by

Ngọc Vi Cao
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Week 1 Part 1 Fundamentals

The document introduces programming concepts using MATLAB, emphasizing its importance in problem-solving and engineering. It outlines the four essential steps in program design: specification, algorithm design, coding, and execution, illustrated with an example of calculating the volume of a cone. Additionally, it mentions the use of MATLAB Online and provides a link to a live script for further learning.

Uploaded by

Ngọc Vi Cao
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Fundamentals

Where do I find MATLAB? Here!

Do I have to have MATLAB installed on my computer right


now? No, you can use MATLAB Online!

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 1


Table of Contents
What is Programming?
What we've covered this week in Part 1
MATLAB Live Script

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 2


What is Programming?
Programming is the process of creating a set of instructions that tell a computer how to
perform a task. Programming can be done using a variety of computer programming
languages, in this course we’ll be using the MATLAB programming language.

An example of this task could be something as simple as calculating the volume of a


cone or as complex as finding the shortest path between two cities. Programming helps
us solve these tasks or problems in a logical and creative way.

Programming allows you to improve your problem-solving skills and as we know this is a
critical skill to have as an engineer, moreover it is an exciting skill that can broaden your
career possibilities as an engineer as it can be used in various fields.

Computer programming is becoming more important in today’s world as everything


around us requires it, it is part of our daily living even in the little things. With the number
of problems in our world today and their increasing complexities, programming is a way
to create innovative solutions by automating, collecting, managing, calculating, and
analysing data and information accurately.

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 3


What is Programming?
In general, there are 4 steps you should always follow when designing a program:

1. Specification: The description of the task that should be executed by the program
2. Algorithm design: The method that will be used to execute the task must be designed
so that the program adheres to the specification
3. Coding of the algorithm: The algorithm must be written in a programming language
that can be executed by the computer.
4. Execution: The program must be executed with a set of examples that reasonably
cover all the possible cases of data input. If the program does not work properly, the
algorithm will have to be redesigned.

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 4


What is Programming?
Let’s use these 4 steps for the cone volume example:

1. Specification:
• Input – the program reads the given radius and height of the cone.

• Output – the program calculates the volume of the cone, using the formula for a
cone.
2. Algorithm design:
• There are two common methods used to design/plan a program: using pseudocode
or a flowchart.

• Pseudocode uses English statements that describe what a program is to


accomplish, imitating real code. For our example, the pseudocode will look as
follows:

input (radius, height)

volume = 1/3*3.14*r*r*h

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 5


What is Programming?
A flow chart is a diagram that represents the workflow/process of a program, and in our
example, it would look as follows:

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 6


What is Programming?
3. Coding of the algorithm:

As mentioned previously, we’ll be using the MATLAB language in this course, the code
will look as follows
(Run the code below using the Run Section button, ):

%The answer should be 1206.4


radius = 8 %cm
height = 18 %cm
volume = 1/3*pi*radius*radius*height

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 7


What is Programming?
Step 4 would use a few values of radius and height, enter values of your choice
and check with a calculator whether your answers match:
radius_1 = %cm
height_1 = %cm
volume = 1/3*pi*radius_1*radius_1*height_1

Now you try! Write pseudocode for calculating area of a circle below:

Later we’ll see how we write the MATLAB code for the area of a circle in
Mathematical Functions.

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 8


What we've covered this week in Part 1
This week in Part 1 we learnt about:
• What programming is

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 9


MATLAB Live Script
Click on the link below for this lecture’s MATLAB live Script

• Week_1_Part_1_Fundamentals.mlx

© 2023 Introduction to Programming in MATLAB (1), Fundamentals 10

You might also like