Connexions

You are here: Home » Content » Freshman Engineering Problem Solving with MATLAB » Visual Tools for Problem Solving with M-Files

Recently Viewed

This feature requires Javascript to be enabled.

Inside Collection (Course):

Course by: Darryl Morrell. E-mail the author

Visual Tools for Problem Solving with M-Files

Module by: Darryl Morrell. E-mail the author

Summary: This module provides a brief introduction to the use of flow charts and pseudo code as aids in problem solving.

Using an abstract visual representation while developing a program structure is often a useful technique. Several different visual representations have been developed; one of the most comprehensive is UML. Two of the simplest are introduced in this module: flow charts and pseudo code. In both flow charts and pseudo code, elements of the problem solution are described using natural language statements that are visually arranged to show the structure of the program.

A flow chart represents elements of the solution to a problem as statements enclosed in boxes; the sequence in which use elements are performed is identified by arrows connecting the boxes. Figure 1 shows an example flow chart.

Pseudo code represents the elements of the solution to a problem as a sequence of statements. The statements are formatted to show the logical structure of the solution. Figure 2 shows an example of pseudo code.

The following example demonstrates the use of flow charts and pseudo code to develop the structure of a program that solves an engineering problem.

Example 1

The ACME Manufacturing Company is planning to manufacture widgets. There are two different manufacturing processes: one cost $10,000 to implement and can manufacture up to 1000 widgets, while the other cost$100,000 to implement and can manufacture up to one million widgets. In addition to the manufacturing cost, there is a fixed cost of $1 per widget (for packing and shipping each widget to the customer). Consider the problem of calculating the cost per unit to manufacture and ship a given number of widgets. One way to solve the problem is to complete the following steps: • Get the number of widgets to be produced. • Determine the total manufacturing costs. • Determine the total fixed costs. • Determine the total cost. • Compute the cost per unit. Figure 1 shows a flow chart that represents these steps. Figure 2 shows the pseudo code that represents these steps. Figure 2: Pseudo code for the widget production problem. First Pseudo Code Get the number of widgets to be produced. Determine the manufacturing costs. Determine the total fixed costs. Determine the total cost. Compute the cost per unit.  Having developed an initial solution, we can refine those elements whose implementation may not yet be fully defined. In this example, the manufacturing cost depend on the number of widgets to be made; if this number is less than or equal to 1000, the cost is$10,000, while if the number is greater than 1000, the cost is $100,000. We can represent this using the flow chart blocks in Figure 3. The diamond is a conditional; the branch of the flow chart that is actually executed depends on whether the conditional is true or false. Putting this conditional into the complete flow chart gives the flow chart in Figure 4. The conditional is incorporated in the the pseudo code to give the pseudo code in Figure 5. Figure 5: Pseudo code for the widget production problem. Complete Pseudo Code Get the number of widgets to be produced. if number of widgets > 1000 manufacturing costs are$100,000
else
manufacturing costs are \$10,000
Determine the total fixed costs.
Determine the total cost.
Compute the cost per unit.


There are advantages and disadvantages for both flow charts and pseudo code. Advantages of using a flow chart include that it provides a strong visual representation of the program and that it is straightforward for novice programmers to use. The primary disadvantage of using a flow chart is that it is possible to create a flow chart that can only be implemented by "spaghetti code". Spaghetti code is considered extremely bad form for many reasons; in particular, it is hard to understand, debug and modify. The primary advantage of pseudo code is that its structure is clearly related to the available control structures in modern computer languages. Pseudo code has several disadvantages: it is not a very strong visual representation, and it is less straightforward for novice programmers.

Content actions

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks