EGR 141 Computer Problem Solving in Engineering and Computer
Download
Report
Transcript EGR 141 Computer Problem Solving in Engineering and Computer
EGR 141
Computer Problem Solving in
Engineering and Computer Science
Programming Concepts and
the Visual Basic 2005 Environment
Four key areas
•
•
•
•
Designing Computer Applications
Programming Environment
Programming Language
Problem Solving
Designing Computer Applications
Table 1.2: Program Development Process
Analyze the
problem
1
understand the inputs, outputs, and their relationships
Visual Programming & Object-based Programming
Develop the
interface
2
create objects to receive input, display output, and
process the inputs to produce outputs
Event-driven Programming & Structured Programming
Design the logic
3
Code the logic
4
Test and debug
5
Complete the
documentation
6
develop object-event diagram: show all relationships
develop an algorithm (flowchart) to depict the logic
desk check using representative & nonstandard data
translate the design into program code
locate and remove any program errors
organize all the material that describes the program
Programming Environment
Toolbar
Menu bar
Title bar
Project
Explorer
Window
Property
Window
Toolbox
Form
Window
Problem Solving
Problem: Separate the
‘static’ noise from the
valuable information
Example: Remove the
noise from the image
shown.
'Picture is accessed from 0 to width-1, 0 to height-1
'Go from 1 instead of 0 because we can't process edge of the image
For x = 1 To pic.Width - 2
For y = 1 To pic.Height - 2
'fill picwindow with the 3x3 window at the current pixel
'this is the processing window
For i = -1 To 1
For j = -1 To 1
'get the current pixel brightness
r = pic.GetPixel(x + i, y + j).R
g = pic.GetPixel(x + i, y + j).G
b = pic.GetPixel(x + i, y + j).B
pixelval = (r + g + b) / 3
picwindow(i + 1, j + 1) = pixelval
Next j
Next i
newpixelval = 0
'Apply the 3x3 filter using convolution
For i = 0 To 2
For j = 0 To 2
newpixelval = newpixelval + picwindow(i, j) * filter(i, j)
Next j
Next i
'truncate values smaller than zero and larger than 255
newpixelval = Math.Min(Math.Max(Int(newpixelval + bias), 0), 255)
'set the new picture in the new image
newpic.SetPixel(x, y, Color.FromArgb(newpixelval, newpixelval, newpixelval))
Next y
Next x
Problem Solving
Example: In the image
of the rollercoaster,
separate the valuable
edge information from
the rest of the picture.
Problem Solving
1st degree polynomial (line)
y = a0 + a1x + e
2nd degree polynomial (parabola)
e = y - a0 - a1x
y = a0 + a1x + a2x2 + e
e2 = (y - a0 - a1x)2 The squared error
Minimizing the squared error we can obtain the
best parameters for a0 and a1 using:
a1
n xi yi xi yi
n xi2 ( xi )2
and
_
_
Minimizing the squared error we can obtain the
best parameters for a0, a1, and a2 using:
n
xi
xi2
x x
x x
x x
i
2
i
3
i
2
i
3
i
4
i
a0 yi
a
x
y
1
i
i
a2 xi2 yi
_
a0 y a1 x where x represents the average of x
_
and y represents the average of y
Problem: Given information that we know, how can we
predict information that we don’t know?
Example: Use curve fitting to fill in the unknown
information: 1st, 2nd, 3rd, … order fitting
Problem Solving
Use the technique of simplifying this circuit using equivalent resistances into smaller, simpler circuits.
Given the following circuit:
Using Divide and Conquer
techniques to solve basic electronics
problems
If R1 = 24 Ω, R2 = 24 Ω, R3 = 12 Ω, R4 = 36 Ω, R5 = 10 Ω and Vs = 18 Volts, determine the circuit
equivalent resistance (REQ) and the circuit current (I). Also calculate the branch currents through R2,
R3, R4, and R5, and the voltage drops across R1, R2, R3, R4 and R5.
Using Divide and Conquer
techniques to solve basic dynamics
problems
The Language
Sub Main()
'Override CurrentUICulture with the fallback culture
Thread.CurrentThread.CurrentUICulture = New CultureInfo("", False)
Do
'Create a resource manager
Dim MyResMgr As New ResourceManager("VBLocalizedHelloWorld.Strings",
System.Reflection.Assembly.GetExecutingAssembly())
'Print out the "HelloWorld" resource string & directions
Console.WriteLine(MyResMgr.GetString("HelloWorld"))
Console.WriteLine(MyResMgr.GetString("EnterCulture"))
'Get the new culture name
Console.WriteLine(MyResMgr.GetString("NextCulture"))
Dim NewCulture As String = Console.ReadLine()
'Switch to the desired culture
Try
Dim c As CultureInfo = New CultureInfo(NewCulture, False)
Thread.CurrentThread.CurrentUICulture = c
Catch 'Fallback to the default culture if an invalid culture is entered
Thread.CurrentThread.CurrentUICulture = New CultureInfo("", False)
End Try
Learning in the
• Lecture
• Problem-Solving Sessions
• Laboratory
Lecture
• Introduction to engineering
problems and topics
• Using Visual Basic 2005
• Environment
• Programming Language
Problem Solving Sessions
• In-depth explanation for
engineering problems and topics
• Practice through solving problems
• Problem-solving homework
Lab
• Practice using Visual Basic 2005
• Laboratory Assignments
• Laboratory Reports
• Lab Mentors
Laboratory work will be individual
There are none!
Course will Prepare you for
• Programming Applications
• Computer Science
• Engineering and Science
• Mathematics
• Secondary Education with a
minor/focus in Computer Science or
Mathematics
• Using a computer to solve problems
practically
• Using Matlab
Course will not Prepare you for
Cooking an edible meal
Understanding the Stock Market
Playing a good game of golf
Understanding why Oakland
University has a Goose Problem
SPA Activity
SPA Activity
Previous Sources say...
“ …riveting...”
-Oakland University Student
“…absolutely astonishing...”
-Washington Post
“…truly magnificent...”
-Entertainment Weekly
“…earth shattering…”
-New York Times
Previous Sources say...
“Instead of sitting through the lectures I’d rather be riveting.”
-Oakland University Student
“It is absolutely astonishing that a classroom can have so many
ceiling tiles.”
-Washington Post
“This class made being sick truly magnificent.”
-Entertainment Weekly
“I pounded my head against the computer so hard that
the noise was earth shattering.”
-New York Times