SlideShare a Scribd company logo
1 of 37
Civil Engineering
                     Skills


Computer programming
                     CIV1900
                Dr Sam Clarke


                  Introduction
Have you programmed before?
A.   Yes (C++, Java)   25%   25%   25%   25%

B.   Yes (Html, CSS)
C.   Yes (Fortran,
     Matlab)
D.   No




                       A.    B.     C.    D.
How this fits in...
   There are 5 weeks of material that combine a
    short lecture (~ 30 mins), with a 2 hour
    computer class and a short quiz

   Today’s intro lecture & variables

   There will be two sessions (Wks10 & 11) that
    explain how to accomplish particular
    programming tasks

   The final session is more about computer
    graphics and introduces the programming
    assessment.
Assessment
1.   Final quiz is worth 10% (wk12)
     Portfolio elements
     (printed graphics & code) 10%

2.   4 online tests (weeks 8-11)
     Unlimited attempts, 70% to pass.
     Each worth 1.25%
     You will not be allowed to proceed to the next
     Quiz without successful completion
What is Computer
Programming?
Contents for Lecture 1
   Why engineers need to program

   Computer modelling and its importance
    for engineering problems

   How to write an algorithm to solve an
    engineering task
Contents for Lecture 1
   Why engineers need to program

   Computer modelling and its importance
    for engineering problems

   How to write an algorithm to solve an
    engineering task
What is an Algorithm?

A. A step-by-step       25%   25%   25%   25%
   procedure for
   calculations
B. A random
   computer process
C. The music of algae
D. The principle of
   how a computer
   works

                        A.    B.     C.    D.
What is an Algorithm?

   How a computer executes a process

 Order
 Instructions
 Rules
On famous physicist Richard
Feynman’s blackboard at the
time of his death was the
following statement:




   “What I cannot create
   I do not understand.”
Hence, an ability to program
or, at the very least, an ability
to understand how programs
work, is today a vital
engineering skill that greatly
enhances employability.
Simple Physics




     We will have a look at this later…
Beam Stress
Finite Element Analysis




      You will learn about this in 3rd year
Fluid Dynamics




     You will learn about this in 3rd year
Groundwater flow
Uses
     Many of the examples we have just
      seen involve computer models of
      engineering structures.

     Modelling is a very important
      application of programming.

     Programming can be used to streamline
      a series of repeated tasks.
      (such as routine design)
Uses




Geotechnics
Uses                      Force




  Resistance

                         Angle 1




               Angle 2
Uses




       Can you imagine how
       long this would take by hand!!
Uses
Uses



Angle 1: 0-90° in 0.1° increments (900)
Angle 2: 0-90° in 0.1° increments (900)
810000 combinations...
Uses



  Each pixel represents a calculation
  Automated using computer
  programming
Limitations
   We can only formulate a model for a process
    if we have some understanding of the
    relevant physics.

   This will be a simplification of reality because
    we are unable to include all possible factors –
    we try to include those that our engineering
    judgement deem to be the most relevant.

   This is closure – we choose to close out some
    aspects of reality to focus on others.
Verification & Validation
   Verification is our checking to see that our
    model contains the relevant physics and that
    we solve the equations that we formulate for
    the processes in an appropriate way.

   Validation is our checking that the outputs
    from our model match our expectations of the
    behaviour of the real system.
Example
In order to determine the specification for a new
bridge you need to estimate the probable 200
year discharge on a river.

The traditional method to do this involves
finding the largest event in a year and fitting a
statistical distribution to these annual maxima.

The raw data that your firm have been given are
daily discharge maxima.
Data
By hand, the procedure that we would follow
 to construct the annual maxima is
 something like:
(1) Scroll down through the data finding the
  first and last values in a particular year;
(2) Sort these data in descending order of
  discharge and isolate the top value (the
  annual maximum);
(3) Write this value into a column in a new
  file with the year in an adjacent column;
(4) Move on to the next year and repeat.
Programming
All programming involves is the writing of
  an algorithm such as that just given into
  a language that the computer can
  process and understand.
The particular language we will be using is
  that for the Matlab software.
Other computer languages tend to work in
 similar basic ways.
Repeating Stuff
Known as loops
For…. loops
While… loops
For… loops repeat a set of statements a set
  number of times.
While… loops keep repeating WHILE some
 condition holds.
We will cover this more in Week 11
For our example from the discharge
dataset, imagine we have 32 years of data,
with either 365 or 366 days in a year.
Illustrating algorithms with flow diagrams


                 Process


                 Decision



                 Data
Set Maximum to 0

      Leap
      year
      data                      Loop through
                                NumDays


 Is current    No                    Current
 year a leap             N           value
 year?                   o


Yes      NumDays = 365           Is this >
                                 Maximum
                                 ?
NumDays = 366
                               Yes
Set Maximum to
                          this new value
All of the statements
that we have written
                         On completion of
are themselves           the inner loop write
embedded in a For loop   out Maximum for
where the counter runs   this year
from 1 to 32, meaning
that the annual
maximum for each year
is written out.
Over the next few weeks you will:

• Be taught how to use Matlab and
  gain an experience in writing
  Matlab code.

• Be given an engineering problem
  which you will have to solve using
  Matlab

Thus, by week 12 you should be able
to code up an algorithm yourself.
Next Week…


 Guest lecture on Civil
  Engineering design

Peer Assessment period

More Related Content

What's hot

KNN - Classification Model (Step by Step)
KNN - Classification Model (Step by Step)KNN - Classification Model (Step by Step)
KNN - Classification Model (Step by Step)Manish nath choudhary
 
1.arithmetic & logical operations
1.arithmetic & logical operations1.arithmetic & logical operations
1.arithmetic & logical operationsmukesh bhardwaj
 
Images in matlab
Images in matlabImages in matlab
Images in matlabAli Alvi
 
Summer training in matlab
Summer training in matlabSummer training in matlab
Summer training in matlabArshit Rai
 
Summer training introduction to matlab
Summer training  introduction to matlabSummer training  introduction to matlab
Summer training introduction to matlabArshit Rai
 
Pregel: A System for Large-Scale Graph Processing
Pregel: A System for Large-Scale Graph ProcessingPregel: A System for Large-Scale Graph Processing
Pregel: A System for Large-Scale Graph ProcessingAnupam Das
 
Matlab and Image Processing Workshop-SKERG
Matlab and Image Processing Workshop-SKERG Matlab and Image Processing Workshop-SKERG
Matlab and Image Processing Workshop-SKERG Sulaf Almagooshi
 
MATLAB Assignment Help
MATLAB Assignment HelpMATLAB Assignment Help
MATLAB Assignment HelpEssay Corp
 
Design and Implementation of 8 Bit Multiplier Using M.G.D.I. Technique
Design and Implementation of 8 Bit Multiplier Using M.G.D.I. TechniqueDesign and Implementation of 8 Bit Multiplier Using M.G.D.I. Technique
Design and Implementation of 8 Bit Multiplier Using M.G.D.I. TechniqueIJMER
 
Me 443 2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...
Me 443   2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...Me 443   2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...
Me 443 2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...Erdi Karaçal
 
DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...
DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...
DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...Saikiran perfect
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 90681061992
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlabAman Gupta
 
Circuit analysis i with matlab computing and simulink sim powersystems modeling
Circuit analysis i with matlab computing and simulink sim powersystems modelingCircuit analysis i with matlab computing and simulink sim powersystems modeling
Circuit analysis i with matlab computing and simulink sim powersystems modelingIndra S Wahyudi
 
study Image Vectorization using Optimized Gradeint Meshes
study Image Vectorization using Optimized Gradeint Meshesstudy Image Vectorization using Optimized Gradeint Meshes
study Image Vectorization using Optimized Gradeint MeshesChiamin Hsu
 
Digital image processing
Digital image processingDigital image processing
Digital image processingSubha Selvam
 
Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)
Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)
Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)Karthik Sagar
 
Multi Processor Architecture for image processing
Multi Processor Architecture for image processingMulti Processor Architecture for image processing
Multi Processor Architecture for image processingideas2ignite
 
Parametric Equations with Mathcad Prime
Parametric Equations with Mathcad PrimeParametric Equations with Mathcad Prime
Parametric Equations with Mathcad PrimeCaroline de Villèle
 

What's hot (20)

KNN - Classification Model (Step by Step)
KNN - Classification Model (Step by Step)KNN - Classification Model (Step by Step)
KNN - Classification Model (Step by Step)
 
1.arithmetic & logical operations
1.arithmetic & logical operations1.arithmetic & logical operations
1.arithmetic & logical operations
 
Images in matlab
Images in matlabImages in matlab
Images in matlab
 
Summer training in matlab
Summer training in matlabSummer training in matlab
Summer training in matlab
 
Summer training introduction to matlab
Summer training  introduction to matlabSummer training  introduction to matlab
Summer training introduction to matlab
 
Pregel: A System for Large-Scale Graph Processing
Pregel: A System for Large-Scale Graph ProcessingPregel: A System for Large-Scale Graph Processing
Pregel: A System for Large-Scale Graph Processing
 
Matlab and Image Processing Workshop-SKERG
Matlab and Image Processing Workshop-SKERG Matlab and Image Processing Workshop-SKERG
Matlab and Image Processing Workshop-SKERG
 
MATLAB Assignment Help
MATLAB Assignment HelpMATLAB Assignment Help
MATLAB Assignment Help
 
Design and Implementation of 8 Bit Multiplier Using M.G.D.I. Technique
Design and Implementation of 8 Bit Multiplier Using M.G.D.I. TechniqueDesign and Implementation of 8 Bit Multiplier Using M.G.D.I. Technique
Design and Implementation of 8 Bit Multiplier Using M.G.D.I. Technique
 
Me 443 2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...
Me 443   2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...Me 443   2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...
Me 443 2 tour of mathematica Erdi Karaçal Mechanical Engineer University of...
 
KNN
KNNKNN
KNN
 
DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...
DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...
DESIGN OF SIMULATION DIFFERENT 8-BIT MULTIPLIERS USING VERILOG CODE BY SAIKIR...
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 9068
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
Circuit analysis i with matlab computing and simulink sim powersystems modeling
Circuit analysis i with matlab computing and simulink sim powersystems modelingCircuit analysis i with matlab computing and simulink sim powersystems modeling
Circuit analysis i with matlab computing and simulink sim powersystems modeling
 
study Image Vectorization using Optimized Gradeint Meshes
study Image Vectorization using Optimized Gradeint Meshesstudy Image Vectorization using Optimized Gradeint Meshes
study Image Vectorization using Optimized Gradeint Meshes
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
 
Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)
Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)
Fpga implementation of high speed 8 bit vedic multiplier using barrel shifter(1)
 
Multi Processor Architecture for image processing
Multi Processor Architecture for image processingMulti Processor Architecture for image processing
Multi Processor Architecture for image processing
 
Parametric Equations with Mathcad Prime
Parametric Equations with Mathcad PrimeParametric Equations with Mathcad Prime
Parametric Equations with Mathcad Prime
 

Similar to Why computer programming

The Architect's Two Hats
The Architect's Two HatsThe Architect's Two Hats
The Architect's Two HatsBen Stopford
 
An introduction to Competitive Programming
An introduction to Competitive ProgrammingAn introduction to Competitive Programming
An introduction to Competitive ProgrammingGaurav Agarwal
 
Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementationthe_wumberlog
 
complexity analysis.pdf
complexity analysis.pdfcomplexity analysis.pdf
complexity analysis.pdfpasinduneshan
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challengesDhanu Srikar
 
programming_tutorial_course_ lesson_1.pptx
programming_tutorial_course_ lesson_1.pptxprogramming_tutorial_course_ lesson_1.pptx
programming_tutorial_course_ lesson_1.pptxaboma2hawi
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.pptArumugam90
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptSourabhPal46
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptMard Geer
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxestefana2345678
 
Dynamic programming prasintation eaisy
Dynamic programming prasintation eaisyDynamic programming prasintation eaisy
Dynamic programming prasintation eaisyahmed51236
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisFerdin Joe John Joseph PhD
 
Software Measurement: Lecture 1. Measures and Metrics
Software Measurement: Lecture 1. Measures and MetricsSoftware Measurement: Lecture 1. Measures and Metrics
Software Measurement: Lecture 1. Measures and MetricsProgrameter
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Prashanth Shivakumar
 
Programming of c++
Programming of c++Programming of c++
Programming of c++Ateeq Sindhu
 

Similar to Why computer programming (20)

The Architect's Two Hats
The Architect's Two HatsThe Architect's Two Hats
The Architect's Two Hats
 
251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf
 
An introduction to Competitive Programming
An introduction to Competitive ProgrammingAn introduction to Competitive Programming
An introduction to Competitive Programming
 
Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementation
 
chapter 1
chapter 1chapter 1
chapter 1
 
complexity analysis.pdf
complexity analysis.pdfcomplexity analysis.pdf
complexity analysis.pdf
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
programming_tutorial_course_ lesson_1.pptx
programming_tutorial_course_ lesson_1.pptxprogramming_tutorial_course_ lesson_1.pptx
programming_tutorial_course_ lesson_1.pptx
 
Algorithms overview
Algorithms overviewAlgorithms overview
Algorithms overview
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.ppt
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
Software metrics
Software metricsSoftware metrics
Software metrics
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
 
Dynamic programming prasintation eaisy
Dynamic programming prasintation eaisyDynamic programming prasintation eaisy
Dynamic programming prasintation eaisy
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
 
Software Measurement: Lecture 1. Measures and Metrics
Software Measurement: Lecture 1. Measures and MetricsSoftware Measurement: Lecture 1. Measures and Metrics
Software Measurement: Lecture 1. Measures and Metrics
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01
 
Programming of c++
Programming of c++Programming of c++
Programming of c++
 

More from TUOS-Sam

CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkTUOS-Sam
 
Loops in matlab
Loops in matlabLoops in matlab
Loops in matlabTUOS-Sam
 
Matlab L3 Program Flow
Matlab L3 Program FlowMatlab L3 Program Flow
Matlab L3 Program FlowTUOS-Sam
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlabTUOS-Sam
 
Orthographic Projections
Orthographic ProjectionsOrthographic Projections
Orthographic ProjectionsTUOS-Sam
 
AutoCAD 2014 Introduction
AutoCAD 2014 IntroductionAutoCAD 2014 Introduction
AutoCAD 2014 IntroductionTUOS-Sam
 
Civil Engineering Skills - Introduction
Civil Engineering Skills - IntroductionCivil Engineering Skills - Introduction
Civil Engineering Skills - IntroductionTUOS-Sam
 

More from TUOS-Sam (7)

CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
 
Loops in matlab
Loops in matlabLoops in matlab
Loops in matlab
 
Matlab L3 Program Flow
Matlab L3 Program FlowMatlab L3 Program Flow
Matlab L3 Program Flow
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
 
Orthographic Projections
Orthographic ProjectionsOrthographic Projections
Orthographic Projections
 
AutoCAD 2014 Introduction
AutoCAD 2014 IntroductionAutoCAD 2014 Introduction
AutoCAD 2014 Introduction
 
Civil Engineering Skills - Introduction
Civil Engineering Skills - IntroductionCivil Engineering Skills - Introduction
Civil Engineering Skills - Introduction
 

Why computer programming

  • 1. Civil Engineering Skills Computer programming CIV1900 Dr Sam Clarke Introduction
  • 2. Have you programmed before? A. Yes (C++, Java) 25% 25% 25% 25% B. Yes (Html, CSS) C. Yes (Fortran, Matlab) D. No A. B. C. D.
  • 3. How this fits in...  There are 5 weeks of material that combine a short lecture (~ 30 mins), with a 2 hour computer class and a short quiz  Today’s intro lecture & variables  There will be two sessions (Wks10 & 11) that explain how to accomplish particular programming tasks  The final session is more about computer graphics and introduces the programming assessment.
  • 4. Assessment 1. Final quiz is worth 10% (wk12) Portfolio elements (printed graphics & code) 10% 2. 4 online tests (weeks 8-11) Unlimited attempts, 70% to pass. Each worth 1.25% You will not be allowed to proceed to the next Quiz without successful completion
  • 6. Contents for Lecture 1  Why engineers need to program  Computer modelling and its importance for engineering problems  How to write an algorithm to solve an engineering task
  • 7. Contents for Lecture 1  Why engineers need to program  Computer modelling and its importance for engineering problems  How to write an algorithm to solve an engineering task
  • 8. What is an Algorithm? A. A step-by-step 25% 25% 25% 25% procedure for calculations B. A random computer process C. The music of algae D. The principle of how a computer works A. B. C. D.
  • 9. What is an Algorithm?  How a computer executes a process  Order  Instructions  Rules
  • 10. On famous physicist Richard Feynman’s blackboard at the time of his death was the following statement: “What I cannot create I do not understand.”
  • 11. Hence, an ability to program or, at the very least, an ability to understand how programs work, is today a vital engineering skill that greatly enhances employability.
  • 12. Simple Physics We will have a look at this later…
  • 14. Finite Element Analysis You will learn about this in 3rd year
  • 15. Fluid Dynamics You will learn about this in 3rd year
  • 17. Uses  Many of the examples we have just seen involve computer models of engineering structures.  Modelling is a very important application of programming.  Programming can be used to streamline a series of repeated tasks. (such as routine design)
  • 19. Uses Force Resistance Angle 1 Angle 2
  • 20. Uses Can you imagine how long this would take by hand!!
  • 21. Uses
  • 22. Uses Angle 1: 0-90° in 0.1° increments (900) Angle 2: 0-90° in 0.1° increments (900) 810000 combinations...
  • 23. Uses Each pixel represents a calculation Automated using computer programming
  • 24. Limitations  We can only formulate a model for a process if we have some understanding of the relevant physics.  This will be a simplification of reality because we are unable to include all possible factors – we try to include those that our engineering judgement deem to be the most relevant.  This is closure – we choose to close out some aspects of reality to focus on others.
  • 25. Verification & Validation  Verification is our checking to see that our model contains the relevant physics and that we solve the equations that we formulate for the processes in an appropriate way.  Validation is our checking that the outputs from our model match our expectations of the behaviour of the real system.
  • 26. Example In order to determine the specification for a new bridge you need to estimate the probable 200 year discharge on a river. The traditional method to do this involves finding the largest event in a year and fitting a statistical distribution to these annual maxima. The raw data that your firm have been given are daily discharge maxima.
  • 27. Data
  • 28. By hand, the procedure that we would follow to construct the annual maxima is something like: (1) Scroll down through the data finding the first and last values in a particular year; (2) Sort these data in descending order of discharge and isolate the top value (the annual maximum); (3) Write this value into a column in a new file with the year in an adjacent column; (4) Move on to the next year and repeat.
  • 29. Programming All programming involves is the writing of an algorithm such as that just given into a language that the computer can process and understand. The particular language we will be using is that for the Matlab software. Other computer languages tend to work in similar basic ways.
  • 30. Repeating Stuff Known as loops For…. loops While… loops For… loops repeat a set of statements a set number of times. While… loops keep repeating WHILE some condition holds. We will cover this more in Week 11
  • 31. For our example from the discharge dataset, imagine we have 32 years of data, with either 365 or 366 days in a year.
  • 32. Illustrating algorithms with flow diagrams Process Decision Data
  • 33. Set Maximum to 0 Leap year data Loop through NumDays Is current No Current year a leap N value year? o Yes NumDays = 365 Is this > Maximum ? NumDays = 366 Yes
  • 34. Set Maximum to this new value All of the statements that we have written On completion of are themselves the inner loop write embedded in a For loop out Maximum for where the counter runs this year from 1 to 32, meaning that the annual maximum for each year is written out.
  • 35. Over the next few weeks you will: • Be taught how to use Matlab and gain an experience in writing Matlab code. • Be given an engineering problem which you will have to solve using Matlab Thus, by week 12 you should be able to code up an algorithm yourself.
  • 36.
  • 37. Next Week… Guest lecture on Civil Engineering design Peer Assessment period