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

Machine Problem 1A

This document provides instructions for students on completing their first exercise in a computer programming laboratory class using Matlab. The objectives are to familiarize students with the Matlab interface and basic commands. The document explains how to open and exit Matlab, access help, use the command window to perform calculations, view the command history, and work with other Matlab tools like directories and the workspace. It provides two practice problems for students to solve using Matlab commands and submit their work.

Uploaded by

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

Machine Problem 1A

This document provides instructions for students on completing their first exercise in a computer programming laboratory class using Matlab. The objectives are to familiarize students with the Matlab interface and basic commands. The document explains how to open and exit Matlab, access help, use the command window to perform calculations, view the command history, and work with other Matlab tools like directories and the workspace. It provides two practice problems for students to solve using Matlab commands and submit their work.

Uploaded by

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

CS10-8L: Computer Programming Laboratory

Exercise #1: Getting Started

Name: Score:

Section: Date:

OBJECTIVES
 To familiarize the students in Matlab interface.
 To enable the students to use some basic commands.

GRADING SYSTEM

From (%) To (%) Grade

0.00 64.99 5.00


65.00 68.89 3.00
68.9 72.89 2.75
72.9 76.79 2.50
76.8 80.69 2.25
80.7 84.59 2.00
84.6 88.49 1.75
88.5 92.39 1.50
92.4 96.29 1.25
96.3 100.00 1.00

INSTRUCTIONS
A. Opening and closing Matlab.
1. To open Matlab, double click the desktop icon or search and click in the programs.
2. To exit Matlab, either click on Exit Matlab from the File menu or typing quit or exit in the Command Prompt
Window. DO NOT click on the close box on the upper right corner.

B. Accessing the Help window.


1. To get in the Help browser, either click on the help button (?) in the desktop toolbar, or select the Help menu in
any tool.
2. Once in the Help browser, select the Contents tab in the Help Navigator pane on the left.
3. To get to the desktop section, expand MATLAB > Getting Started > Development Environment.

C. Using the Command window.


1. Type the following in the Command window, then click Enter:
>> 2+3 <Enter>
>> 3-2 <Enter>
>> 2*3 <Enter>
>> 1/2 <Enter>
>> 2^3 <Enter>
>> 2\1 <Enter>
2. Also try the following commands:
>> 2 .*3 <Enter>
>> 1 ./ 2 <Enter>
>> 2 .^3 <Enter>
3. Matlab has a useful editing feature called smart recall. Just type the first few characters of the command you want
to recall, say 2*, then press the up-arrow key. This would recall the most recent command starting with 2*.
4. Try the following commands:
>> 0/1 <Enter>

Prepared by: Engr. Cheryl Mari M. Isip


CS10-8L: Computer Programming Laboratory
Exercise #1: Getting Started

>> 1/0 <Enter>


>> 0/0 <Enter>
Matlab will try to warn you in case you didn’t realize you were dividing by zero but will still give you the answer
Inf. In the last command, another special value is obtained NaN, which means Not-a-Number.

5. To assign variables, perform the following commands:


>> x = 2 <Enter>
>> y = 3; z = 4; <Enter>
>> w = x + y - z <Enter>

E. Browsing the Command History window.


1. You can run a command again by simply double clicking on it. Double click on w = x + y – z
2. To alter the command before running it, click and drag the command to the Command window, change it, and
then hit enter. Drag w = x + y – z then change it to w = x + y + z.

F. Familiarizing with other tools.


1. To change the file location you are working on, click on the Current Directory tab and type or browse to the
correct address.
2. The Directory shows the files in the current directory. The files can be run by double clicking and dragging them
into the Command window.
3. The Workspace keeps track of the variables that are created. Double click on x and change the value to 4.

MACHINE PROBLEM
Answer the following problems using commands in Matlab. Make sure to indicate your commands in your
submission and .
1. Compute the following using the correct order of operations:
a. 2−4∗(5 3−2+2∗( 5+6 ))
4∗5 3−2
b. 2−
2∗(5+6)
4∗53−2
2−
c. 2
+6
5
2. Compute for the volume of a truncated pyramid with a = 5, b = 3 and h = 10, given the formula:
1
V = ( a2 +ab+ b2 ) h
3

Prepared by: Engr. Cheryl Mari M. Isip


CS10-8L: Computer Programming Laboratory
Exercise #1: Getting Started

ANSWERS
1.
a. Answer:
Command:

b. Answer:
Command:

c. Answer:
Command:

2. Answer:
Command:

Prepared by: Engr. Cheryl Mari M. Isip

You might also like