Beruflich Dokumente
Kultur Dokumente
Introduction to Computing
CSL-111
LAB JOURNAL
Name: __________________________________________
Section: _________________________________________
2
DEPARTMENT OF ELECTRICAL ENGINEERING
Exp. Obtained
Experiment Name Date Sign
No Marks
1 Building up the Computer System
7 Introduction to MS Excel
8 Fundamentals of Pseudocodes
14 Basics of MATLAB
3
Total Marks: _______________ Signature: _________________
4
EXPERIMENT 01
Background
What is a Computer?
• [Norton] A Computer is an electronic device that processes data, converting it into
information that is useful to people
• [Wikipedia] A Computer is a programmable device, usually electronic in nature, that can
store, retrieve and process data
• [The American Heritage Dictionary]
1. A device that computes… especially a programmable electronic machine
that performs high-speed mathematical or logical operations or that
assembles, stores, correlates, or otherwise processes information
2. One who computes
It is necessary that you are aware of the hardware in your computer. While the operating system
usually takes care of the complexity of managing the hardware of your computer system,
knowing the hardware helps when you have to:
5
2) Upgrade your computer system
3) Diagnose and repair problems in your computer system
Tasks:
1) Familiarize yourself with the following basic tasks specific to Windows operating systems
[ask your instructor if you have problems]:
a) Copying/ pasting a file [select a file, right click> copy; go to the directory to paste into, right
click > paste]
Solution
b) Creating a new file [hint: right click > new > file type]
Solution
c) Creating a new folder [hint: right click > new > folder]
6
Solution
e) Finding how to find Windows help [hint: click on Windows Start button, and then on Help
and Support, explore what kind of help is available]
Solution
7
2) To check the hardware present in your computer, Right click on My Computer and then click
on Properties note down the specifications of the PC you are working on the default tab.
Solution
8
a. What is the Operating System being used? (write complete details)
Solution
Solution
9
d. What is the amount of RAM present?
Solution
Solution
10
a. What is the computer’s description?
Solution
4) Click on the Hardware tab and then on Device Manager, note all information about hardware
devices here and answer the following questions?
11
Figure: 1.3 Device Manager
(Hint: you can right-click on any device and see further properties)
Solution
12
c) Does the computer have a network adapter?
Solution
d) What is the name of the monitor? Is the proper driver of the monitor installed? What is the
name of the provider of the driver for the monitor?
Solution
F1: Help
13
Windows Logo+R: Run dialog box
Windows Logo+D: Minimizes all open windows and displays the desktop
d) Open search
Solution
14
f) Move the cursor to address bar in internet explorer
Solution
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
15
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
16
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details
EXPERIMENT 02
Objectives
To develop understanding of Operating system basics command line interface through MS DOS.
Background
17
The Command Prompt
C:/>
This is called the command prompt, the flashing underscore next to the command prompt
is called cursor. The cursor shows where the command you type will appear.
Nul
1- If you make a typing mistake, press the BACKSPACE key to erase the mistake, and then
try again.
2- Press ENTER.
2- Changing Directories
18
Type the following at the command prompt:
cd windows
The command prompt changes. It should now look like the following:
C:\WINDOWS>
b) Change from one directory to another.
Solution
dir /p
When you used the /p switch with the dir command, you specified that MS-DOS should pause
after it displays each screen of directory list information. The p stands for "page".
dir /w
If the directory contains more files than will fit on one screen, you can combine the /p and /w
switches as follows:
19
dir /w /p.
5- Creating a Directory
In this section, you will create two directories. Creating a directory is helpful if you want
to organize related files into groups to make them easy to find. Before you begin this
section, make sure the command prompt looks like the following:
C:\>
To create a directory, you will use the md command. The md command stands for "make
dir
To create and change to a directory named FRUIT
1. Type the following at the command prompt:
2. md fruit
3. Dir
To change to the new FRUIT directory, type the following at the command prompt:
cd fruit
The command prompt should now look like the following:
C:\FRUIT>
You will now create a directory within the FRUIT directory, named GRAPES.
To create and work with a directory named GRAPES
1. Type the following at the command prompt:
md grapes
Confirm that you successfully created the GRAPES directory?
To change to the GRAPES directory, type the following at the command prompt:
cd grapes
20
The command prompt should now look like the following:
C:\FRUIT\GRAPES>
1. To switch back to the FRUIT directory, type the following:
cd..
d) Create directories.
Solution
6- Deleting a Directory
In this section, you will delete the GRAPES directory. Before you begin this section, make sure
the command prompt looks like the following:
C:\FRUIT>
To delete a directory, use the rd command. The rd command stands for "remove directory."
e) Delete directories.
21
Solution
7- Changing Directory
C:\FRUIT>
Type the following at the command prompt:
d:
f) Change from one drive to another.
Solution
8- Copying Files
Before you begin this section, make sure the command prompt looks like the following:
C:\FRUIT>
To copy the NOTEPAD.EXE files from the WINDOWS directory to the FRUIT directory
1. Return to the root directory by typing the following at the command prompt:
cd\
The command prompt should now look like the following:
C:\>
2. Change to the DOS directory by typing the following at the command prompt:
cd windows
The command prompt should now look like the following:
C:\WINDOWS>
3. To copy the NOTEPAD.EXE file from the WINDOWS directory to the FRUIT
directory, type the following at the command prompt:
copy c:\windows\notepad.exe c:\fruit
22
4. To confirm that you copied the files successfully, view the contents of the FRUIT directory by
typing the following at the command prompt:
dir \fruit
g) Copying files.
Solution
9- Rename a file
To rename a file, you will use the ren command. The ren command stands for "rename."
When you use the ren command, you must include two parameters.
ren old name new name
Before you begin this section, make sure your command prompt looks like the following:
C:\FRUIT>
1. To rename the NOTEPAD.EXE file to PADNOTE.TXT, type the following at the
command prompt:
ren notepad.exe padnote.txt
h) Rename the file.
Solution
23
1. Delete the PADNOTE.TXT file by typing the following at the command prompt:
del PADNOTE.TXT
To delete the FRUIT directory
2. Return to the root directory by typing the following at the command prompt:
cd \
3. You can see the FRUIT directory in the directory list by typing the following at the
command prompt:
dir or dir /p
4. Remove the FRUIT directory by typing the following at the command prompt:
rd fruit.
i) Deleting the file.
Solution
Tasks:
How are the following operations done in MS DOS?
1) Show the version of windows.
Solution
2) Show help
Solution
24
3) Show time
Solution
4) Show volume
Solution
b. Pause
Solution
d. cls
Solution
25
Home task
How are the following operations done in MS-DOS? Give the syntax and explain the command
(all answers must be typed along with the questions to be in BOLD)
1. Net
Solution
2. Ping
Solution
3. Set
Solution
4. Assign
Solution
26
5. Attrib
Solution
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
27
Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)
improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
EXPERIMENT 03
28
Introduction to Web Development
Objectives
Background
Hypertext:
“Hypertext most often refers to text on a computer that will lead the user to other, related
information on demand. Hypertext allows a form of user interface, which overcomes some of the
limitations of written text. Rather than remaining static like traditional text, hypertext makes
possible a dynamic organization of information through links and connections (called
hyperlinks). Hypertext can be designed to perform various tasks; for instance, when a user
"clicks" on it or "hovers" over it, a bubble with a word definition may appear, a web page on a
related subject may load, a video clip may run, or an application may open.” [Wikipedia]
HTML:
HTML is a hypertext markup language that is used to describe the structure of a webpage using
tags. A web browser, an application that understands HTML tags and displays web pages
accordingly, utilizes the HTTP protocol to receive HTML pages from a web server (also called
HTTP server).
It is important to note that the display of an HTML page in a browser is not the same text that we
see if we were to edit the HTML page in a text editor. This is because the HTML file itself
contains many instructions/ tags that are not displayed in the browser. The function of these tags/
information is simply to enable a browser to display the HTML file. This should become clear as
we go through the exercises.
29
In this part, we will create a directory in which we will save today’s lab work. We will
also learn how to create and save index.html and format.css files.
On the desktop, create a folder named ITCLab3
[Hint: this can be done by right clicking on the desktop, and then choosing New and then
Folder]
Create an index.html.
Open the Notepad application. [Start > Programs > Accessories > Notepad]
Save the empty file as index.html by clicking on the File menu of the Notepad.
On the file menu, choose “Save As”. The “Save As” window will appear as shown below:
In a similar manner, create the format.css file. [We will later see how this file is used]
30
Save the empty file as index.html on the Desktop. [We will use the Desktop as HTML
playground, and once the files have been finalized, then they will be transferred to the ITCLab2
folder.] To save the file as index.html, index.html must be written as the file name with the “Save
as type” set to All Files.
• Note: As explained the “Save as type” should be set to All Files, if the “Save as type”
field is set to Text Documents (*.txt) then the file would be saved as index.html.txt
and not as index.html.
• In the figure above, we do not have any HTML code in between the <html> tags. We
will now start to code the HTML page.
31
• We will name the title of our webpage as ITC lab 03. Note how the title text is
enclosed in the head tags and the title tags.
Open the index.html file on the Desktop (modified as above) with Internet Explorer (this can be
done by simply double clicking on the index.html file). You will find that the Internet Explorer
displays “ITC Lab 03” as the title of the web page as configured in the figure above. The
webpage is still empty as we have not added any text in the main page’s body yet (we will do
that soon).
For now, the index.html page should look like the following.
• Copy the index.html into the ITCLab3 folder on Desktop and rename it as Title.html.
[Hint: a file can be renamed by selecting, right clicking, and choosing the rename
option.]
32
Figure: 3.6 Inserting Text
• After saving the index.html file on Desktop, open the file in a browser (by double
clicking on the file). If the index.html file is properly configured, the browser display
should be as follows. You will notice that all there is no line break, and all the text we
had put between the <body> tags is on one line.
• A browser has to be told by HTML tags where line breaks, new paragraphs, etc.
should occur. Since we have not used those tags yet, all the text is on one line as
shown in the figure below.
• Save the index.html file on the Desktop in the ITCLab3 folder as Allon1line.html.
33
Figure: 3.8 Inserting Line Break
• After making the changes, save the index.html file and open it using a browser. The
browser should display the page with proper line breaks as shown in the figure below.
You will see that all the text is not on the same line any more.
• If you see the browser display as above, save the index.html file on the Desktop to the
folder ITCLab3 as Linebreak.html.
5. Insert a paragraph
• In the figure above, all the text is in a single paragraph (although separated by line
breaks). To start a new paragraph, the HTML tag <p> should be used. The tag <p> is
used to mark the start of a paragraph, and the end of paragraph is marked by </p>.
• To observe how a paragraph is formatted in HTML, open the index.html file on the
Desktop. Make the changes highlighted in the following figure and then save the file.
34
Figure: 3.10 Inserting Paragraph
• Open the index.html file on the Desktop (modified with the changes highlighted
above) with a browser. You will see now that the web page is composed of two
paragraphs. The second paragraph also has line breaks within the paragraph. The
browser display should look like the following.
• If you see the browser display as above, save the index.html page on the Desktop to
the ITCLab3 folder and name it as Paragraph.html.
6. Inserting headings
35
In the index.html file on the Desktop, currently no text is highlighted as a heading. If certain
text is to be a heading, the HTML tags <h1></h1>, <h2></h2>, <h3></h3>, <h4></h4>
(and so on) may be used. The tag <h1> is used for bigger sized heading with the heading size
decreasing for <h2> <h3> and so on.
Open the index.html file on the Desktop and make the changes highlighted in the following
figure. The first paragraph is highlighted using the <h1> tags.
• After making the changes in the index.html file on the Desktop as shown above, save
the file. Open the file now with a browser. The browser display should look like the
following. You will note that the first paragraph now highlighted as a heading with a
large sized font.
36
Figure: 3.13 Inserting Headings Display
7. Inserting a hyperlink
We will now add a hyperlink on the index.html file. Open the index.html file on the Desktop and
make the change highlighted in the following figure.
• Save the file after making the change highlighted above. Open the file using a
browser. You should see that the browser display is similar to as shown below. You
will observe that a hyperlink to the specified URL is now added. Click on the URL
and note where the target of the hyperlink.
• If the browser display is similar to as shown above, save the index.html file on the
Desktop to the folder ITCLab3 as Hyperlink.html.
37
Figure: 3.15 Inserting Hyperlink Display
We will now see how a text can be italicized, underlined, or made bold in HTML. The tags for
these tasks are, respectively, <i></i>, <u></u> and <b></b>.
38
• Italicizing: To italicize a body of text, it must be enclosed in <i> </i> tags. To
demonstrate this, open the index.html file on the Desktop and make the changes
highlighted in the following figure.
• After making the changes shown above, save the file and then open in using a
browser. You will observe that the text between the <i> and </i> tags is italicized. If
the browser display is as shown below, save the index.html file in the ITClab2 folder
as ItalicsAndUnderline.html.
39
Figure: 3.19 Inserting text italic, underline or bold Display
• The HTML page will include the file taimur.jpg as an image. For this to work,
taimur.jpg should be in the same folder as the index.html file. Download the
taimur.jpg file from the course website and place on the Desktop. With the image file
also on the Desktop, open
40
Figure: 3.20 Inserting table and image
• The index.html file using a browser. You should be able to see the image as part of the
web page displayed in the browser
Tasks
1. Create and save an html file
41
Solution
Solution
Solution
42
4. Insert some text onto the webpage
Solution
43
5. Format the text through line breaks
Solution
6. Insert a paragraph
Solution
44
7. Insert headings -> h1, h2, h3 etc.
Solution
8. Insert hyperlinks
45
Solution
46
9. Italic, bold and underline the text in paragraphs
Solution
Solution
47
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
48
improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
EXPERIMENT 04
49
Objectives
To become familiar with word processing and enable students to use the various tools in MS
Word effectively to perform common word processing tasks quickly.
Background
Explore Window
Following is the basic window which you get when you start word application. Let us understand
various important parts of this window.
Backstage View
50
The Backstage view has been introduced in Word 2010 and acts as the central place for
managing your documents. The backstage view helps in creating new documents, saving and
opening documents, printing and sharing documents, and so on.
Review Tab
The easiest way to correct spelling mistakes is to right click any word that has a red wavy
underline
To check more than one word at a time, you can bring up the Spelling and Grammar dialogue
box. To see it, click on the Review tab at the top of Word. On the Review tab, locate the
Proofing section. Then click Spelling & Grammar:
51
Figure: 4.4 Spelling and Grammar
Word count provides the statistics that how many pages, lines and paragraphs etc. are in our
document
Another way To know the current word count of a document, open the document and right click
on the status bar at the bottom of the Word window. The context menu which comes up will
have an entry named “Word Count” which will tell you the current word count.
52
Figure: 4.6 Alternate for Word Count
To insert a comment first select the text then go to “New Comment” on “Comments” group in
“Review” tab. Click on “New Comment” and a new comment will be inserted. You can also
move to next or previous comments and can also delete the comments using this “comments”
group.
To insert a comment in a document, highlight the area of text where you want to comment on.
Click the Review tab on the Ribbon then click New Comment
53
Tracking Group:
With this feature of tracking, you can track and view all changes that are made to the document.
1. While in the document, On the Review tab, under the Tracking group, click Track
Changes.
1. On the Review tab, in the Changes section, click the Next button to move to the next change.
2. Click the Accept or Reject button to accept the change or reject the change and move to the
next change.
3. Keep going until you’ve responded to all the changes.
In “Compare” group there is an option to compare two different documents. This option is
usually used to find out the similarity between two different documents
54
After browsing the paths for original and revised documents click” ok”. A new document will be
opened that will highlight the changes present in the both documents.
View Tab
View tab is used to change the document views. Go through each view and observe the changes
that each view brings.
With MS Word 2010 there is also Quick Access Toolbar which has a save, undo Repeat Typing
button and Customize Quick Access drop down list. Within the list there are New, Open, Save,
E-mail, Quick Print, Print Preview and Print, Spelling & Grammar, Undo, and Redo, Draw
Table, Open Recent File icons. You can also choose to show the Quick Access Toolbar below the
Ribbon by choosing Show below the Ribbon selection and you can also customize further with
the More Commands button and make Microsoft Word 2010 suitable to your preferences and
needs. In such a manner Quick Access Toolbar of MS Word lets you performance routine tasks
much faster. The Microsoft Word 2010 Quick Access toolbar and its functionality are shown
below
Tasks:
Formatting Text
A computer is a device that accepts information (in the form of digitalized data) and manipulates
it for some result based on a program or sequence of instructions on how the data is to be
processed. Complex computers also include the means for storing data (including the program,
which is also a form of data) for some necessary duration. A program may be invariable and built
into the computer (and called logic circuitry as it is on microprocessors) or different programs
may be provided to the computer (loaded into its storage and then started by an administrator or
user). Today's computers have both kinds of programming.
55
1) Copy the above text and paste in y0ur document.
Solution
2) Copy the last sentence today’s computers have both kinds of programming to the
beginning of the first paragraph.
Solution
56
5) Change the spacing of the entire document from single spacing to 1.5.
Solution
57
7) Set the phrases logic circuitry and microprocessors in Italic.
Solution
58
10) Change the text in form of bullets.
Solution
59
13) Insert Page Numbers
Solution
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
60
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
61
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
EXPERIMENT 05
Objectives
62
To become familiar with word processing and enable students to use the various tools in MS
Word effectively to perform common word processing tasks quickly.
Background
Reference Tab
This tab provides the quick way to create table of contents, update it, enter citations or
references, choose any writing styles and footnotes etc. For generating the table of contents first
selects the text from the document to appear in it. After selecting the text, make it a heading from
“Styles” group in home tab. After making different headings, go to “Table of Contents” option in
“Table of Contents” group of “Reference” tab and select any one format.
In “Footnotes” group there is an option to add footnotes and endnotes. Footnotes and endnotes
are an easy way to add or provide the reader with supplementary information and that
information will appear at the end of the page.
To insert a footnote or endnote, navigate to Footnotes section. To insert a footnote, click the
menu option with text as AB1Insert (Placeholder1) Footnote
63
Figure: 5.2 Footnotes
The keyboard shortcuts for inserting a Footnote are Alt + Ctrl + F for inserting an Endnote is
Alt + Ctrl + D
Similarly, citations and bibliography can be inserted from “Citations and Bibliography” group.
The writing styles can also be changes from here as citations depend upon it. In technical writing
we have many different styles of writing that can be select from this group of “Reference” tab.
In “Captions” group, one can give captions to the figures and hence can create the table of
figures in the same manner as table of content were created.
64
Figure: 5.5 Table of Figures
Mailing Tab
We can create, and print envelops and labels using this tab. “Start mail merge” are used to create
a form letter which one uses for printing and sending purpose. We can select the recipient also.
Insert Tab
Click the Insert tab and click Table button. This will display a simple grid shown below. When
you move your mouse over the grid cells, it makes a table in the table which appears in the
document. You can make your table having desired number of rows and columns
65
Figure: 5.7 Insert Tab
Click the square representing the lower-right corner of your table, which will create actual table
in your document and word goes in table design mode giving lots of options to work with table
as shown below.
Following are the simple steps to “delete” an existing table from a word document.
66
Figure: 5.9 Layout
67
Figure: 5.10 Formula Button
Following are the simple steps to “add an existing picture” in your word document. It is
assumed that you already have a picture available on your PC before you add this picture in your
word document.
Step (1): Click in your document where you want to add a picture.
Step (2): Click the Insert tab and then click Picture option available in illustrations group,
which will display Insert Picture dialog box.
68
Figure: 5.11 Insert Picture Dialogue Box
Similarly, you can insert Clip Art, Shapes, and Charts etc.
Task
Solution
69
2. Write your name and registration number and insert footnote that shows your academic
qualification.
Solution
3. Write on any topic of your choice and insert a comment (not more than three lines).
Solution
70
4) Using the data given in task 1 use mailing tab to mail the training date to the given
people.
Solution
71
4. Insert table of contents that provides the reference to different tasks.
Solution
72
5. Show “X Y Scatter plot”
Solution
a. Exponential
Solution
73
b. Matrix
Solution
c. Binomial formula
Solution
d. Quadratic formula
Solution
e. Integral
Solution
74
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
_____________________________________________________________________________
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
75
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations
EXPERIMENT 06
Objectives
Background
Microsoft Power Point
Home Tab
To begin Microsoft PowerPoint, go to Start Menu > All Programs > Microsoft Office >
Microsoft PowerPoint 2010. Select PowerPoint Presentation from the Project Gallery if a blank
document does not open.
The Design Ribbon toolbar contains several categories for formatting the design and elements of
your presentation. These include: Home, Insert, Design, Transitions, Animations, Slide Show,
Review and View. The brief introduction of these tabs is;
The Home bar: This has features that allow you to edit Slides, Fonts, Paragraph, Drawing
and Editing.
76
The Insert bar: This has features that allow you to add Tables, Images, Illustrations,
Links, WordArt, and Media Clips.
The Design bar: This allows you to edit how your presentation will look. It includes
features such as Page Setup, Themes, and Background Styles.
The Transitions bar: This allows you to edit Slide Transitions, Effects, and Transition
Timing. The Animations bar: This allows you to add custom animations to your
presentation. You can select from Preview, Animations, Advance Animation, and
Animation timing.
The Slide Show bar: This has features that allow you to select how your presentation will
be displayed. From here, you can start your Slide Show, Set Up your Slide Show, and
Adjust Monitor Settings.
The Review bar: This allows you to Proofread, Translate Languages, Comment Slides,
and Compare your Presentation.
The View bar: This has features that allow you to set the View of your Presentation,
Create Master Views, Show/Hide Features, Zoom, Switch from Color to Grayscale,
Adjust Windows, and Add Macros.
1. To create a new slide where you can add content, click the Home tab and select New Slide.
2. Clicking the bottom half of New Slide will give you different new slide options.
77
title and content slides
comparison slides
two content
picture with caption slides
and more
These layouts of slides will define the appearance of the slide and the way one can put data into
the slides. The layout of the slides can also be change after they are inserted. In Slides group,
there is a drop-down menu named as “Layout”. By clicking on layout tab and selecting a layout
style, the style of current slide can be changed.
In this tab there is option to cut copy and paste the text. These options are available in
“clipboard” group of Home Tab. Shortcut keys for copy, cut and paste commands are Ctrl+c,
Ctrl+x and Ctrl+v respectively.
Font group allows you to change the font of the text, size, and case etc. of the text. Select the text
first then perform any operation.
In order to change the case of text, select the text you want to change then go to Font group of
Home Tab and choose an option from drop down list.
The simplest way to change the way your text looks is to use Bold, Italics, Underline
button on the formatting tool bar. To apply these, just click the button you want your text to be
formatted into. Formatting text involves Underline, Bold, Italic, and Text in different Fonts, Text
in different font sizes, and text in different colors.
Similarly, you can change the text color, outline and appearance etc.
78
You can make the lists by using bullets, numbering and multilevel list in the “Paragraph Group”.
1. Select the paragraphs you want to format
2. Click the Home tab on the Ribbon and click the Bullets or Numbering button in the
paragraph group
Click the list arrow on each button to apply a different style of bullets or numbering
Multileveled lists apply different bullets or numbering to the different levels of a list.
1. Select the paragraphs you want to format
2. Click the Home tab on the Ribbon and click the list arrow on the Multilevel List button in the
paragraph group
79
Figure: 6.5 Styles of Bullets
1. On the home tab of the ribbon, look for the paragraph group. Then click on the Line Spacing
button, as shown in the image below.
Select your desired line spacing. From this menu you can select to have your line spacing set to
1, 1.15, 1.5, 2, 2.5 or 3.
80
Figure: 6.8 Line and Paragraph Spacing
After selecting from Text Direction, the text’s direction will be changed on slide.
To change the alignment of text within the text box, follow the following steps;
Select the text. Go to Home tab then in “Paragraph” group.
Click on “Align Text” option. Select any one option.
81
Figure: 6.10 Align Text
You can change the colors applied to the shapes in your SmartArt graphic. The different color
combinations are all derived from the theme colors of your presentation.
1. Click the SmartArt graphic.
2. Under SmartArt Tools, on the Design tab, in the SmartArt Styles group, click Change
Colors.
If you don't see the SmartArt Tools or Design tabs, make sure that you've selected a SmartArt
graphic. You may have to double-click the SmartArt graphic to select it and open the Design tab.
82
3. Click the color variation that you want.
The figure shown below states the conversion of the text into SmartArt. It shows how the plain
bulleted text is converted into a professional design.
“Drawing” Group of home tab is used to create different type of shapes like square etc.
Shape outline, color and effects can be changed using the same group in Home Tab.
Find Replace option in editing group:
1. On the “Home” tab of the Ribbon, go to the “Editing” group, and select “Find” … or use the
shortcut key CTRL+F.
2. Type the word you want to find, and then press enter.
If you want to make a change to a specific word, you want to use the replace functionality. To
replace a word/s in PowerPoint:
1. Go to the “Editing” group, and select “Replace”, or use the shortcut key CTRL+H
2. In the “Find what” text box, type the word you want to find
83
3. In the “Replace with” text box, type the word that you want to replace the original word with
4. To replace words one at a time, click “Replace”, if you want to replace every occurrence of the
word in the document, click “Replace All”
Insert Tab
First group in insert tab is “Tables”. On selecting the “table”, different option will appear from
where rows and columns can be selected.
Click on the arrow underneath Table. This will open up a new box with several options
for creating a table.
If you select the Insert Table option, a dialog box will appear where you can enter more
exact specifications for the table.
Next group is “Images” group. Any picture placed in any directory of the computer can be
accessed using “Picture” option of this group and can be inserted in slides. Similarly Clipart can
also be inserted using this group.
84
Figure: 6.16 Insert Images
It has an option of getting Screenshots. PowerPoint will automatically take the screenshots of
already opened windows and gives the option to select the screenshot and insert in slide.
Click on the. It will give an option to create a new album or edit the existing one.
On clicking the new photo album, the dialogue box is opened
On selecting multiple files for album, a new presentation will be generated having all those
selected pictures.
Shapes, SmartArt and charts can be inserted using the “Illustrations” group of the “Insert” tab.
Adding Audio / Video to PowerPoint presentation:
85
4. If you want to hide the audio file during slide show, select “Automatically” from Play sound
drop down menu and check the Hide during show option in the sound options group
Adding Hyperlink:
Select the text or image to link to insert a hyperlink. From right-click menu, click Hyperlink
option
This will bring up Insert Hyperlink dialog, from left side bar, select place in This Document,
from center pane, select a slide to create link with and click OK.
86
Figure: 6.20 Insert Hyperlink
Task:
1) Create Photo Album & Hyperlink
Insert one new slide and put a text for example: “My Photo Album”
Create one photo album and adjust your text and your photos
Save your photo album with a new file
Make a hyperlink to your photo using the text “My Photo Album”
Solution
87
2) Convert “text” into “SmartArt” and write down how you did this.
Solution
88
3) Insert the following equation
Solution
89
4) Insert the slide number, footer (your enrollment) and date. Write your name
and rotate it to 270o.
Solution
90
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
91
Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)
improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
EXPERIMENT 07
92
Introduction to MS Office Excel
Objectives
MS Excel is spreadsheet software in the Microsoft Office Suite. Excel allows you to store
manipulate and analyze data in organized workbooks for home and business tasks
93
Opening an Existing Workbook
a. Go to the File Button menu and click on ‘Open’
b. A window appears with some path set (typically ‘My Documents’). The left-hand side of
the window shows some links that allow you to browse through different folders and
change the path
c. Go to the folder where the workbook you want to open is located, select the workbook
and click open
a. Text Alignment
You can left align text
You can right align text
You can center align you text
You can top align text
You can middle align text
You can bottom align you text
b. You can change text orientation, wrap text and merge & center multiple cells as well
94
Figure: 7.2 Sheet
95
1. To chart your data in a worksheet
a) Make this table in Excel worksheet
c) On the Insert tab, in the Charts group, click the chart type that you want to use, and then
click a chart subtype.
96
a. If you want the chart to keep its look and appearance from the Excel file,
select Keep Source Formatting & Link Data
b. If you want the chart to use the look and appearance of the PowerPoint
presentation, select Use Destination Theme & Link Data
f) You can edit chart data in PowerPoint or in Excel by pressing Right Click->Edit Data
Tasks:
1) Sinusoidal Curves: Generate and plot a 101 sampled sine and a cosine wave of 5 Hz
frequency as shown below
•
• where = 5 Hz
97
Figure: 7.9
Solution
98
2) Generate a plot of following polynomials
99
3) Grade sheet
• Create a data that represents the marks obtained by the students in
HomeWork#1, HomeWork#2 and HomeWork#3 (The marks obtained are out of
10 for each homework)
• Add the data for 10 students, the columns hold categories of the data like:
Students | Name | HW # 1 | HW # 2 | HW # 3
• Apply functions on the data such that
• Fifth column contains the total marks obtained by a student in all
the 3 homework.
• Sixth column contains the average of the marks obtained.
• Seventh column contains the percentage.
• Eighth column contains the maximum marks obtained by a
student.
• Ninth column contains the minimum marks obtained by a student.
Solution
100
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
101
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
102
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details
EXPERIMENT 08
Fundamentals of Pseudo-codes
Objectives
The purpose is to gain fundamental skills to plan the logic of a program by ways of developing
simple logical statements.
Background
Pseudo code
Pseudo code omits programming level details (like declaration of variables, looping syntax ...)
and so it makes things very easy to understand for human being and implement it in any
programming language easily.
103
Rules for Pseudo-codes
• Write only one statement per line
• Each statement in your pseudo code should express just one action for the
computer.
• Capitalize initial keyword
• READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL
• End multiline structures
• Use END in IF/ELSE conditions and main program
Example-1
Read a number from user and print it on console
EXAMPLE 2:
104
Figure: 8.2 Pseudocode with if condition
EXAMPLE 3:
Nesting if statements
Tasks:
1. Read in a number and check if the number entered by user is odd or even.
Solution
2. Read in two numbers, call them A and B. If A is greater than B, print out A, otherwise print out
B.
Solution
105
3. Read in a number and display the grade of a student.
Solution
4. Write a program to print the number entered by the user only if the nu mber entered
is negative.
Solution
106
6. Display your name and class
Solution
Solution
107
8. Read in the variables ‘x’ and ‘y’ and get their sum if x>y.
Solution
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
108
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
EXPERIMENT 09
Objectives
109
It is a tool for creating program flowcharts. It helps to gain fundamental skills to plan the logic of
a program by ways of developing an algorithm in the form of flowchart.
Background
The programming process follows a program development lifecycle with its initial steps as
understanding the problem and planning the logic. This session focuses on ‘planning the logic’
where we will learn how to develop an algorithm in the form of flowchart
The starting flowchart displays a “Begin” and “End” symbol as shown. To create a flowchart,
you add symbols between these starting symbols.
110
Hover your mouse over the red arrow between the Begin and End symbols. It will turn green,
indicating that you can click on it to get a popup window. This popup window has the other
symbols we will need to create programs.
Double click on the Output symbol to get the Output dialog box.
Enter your own name and be sure to enclose it within quotes. Later, we will use variables that
don’t use quotes. Click on the “OK” button when done, and the Output symbol will change to
111
show your intended output. Run the program by clicking on the button on the toolbar, or
by pressing the F5 function key.
Example of flowcharts
112
Tasks
1) Develop the logic of a program that takes two numbers and display their multiplication
Solution
2) Develop the logic of a program that takes the radius and height of a cylinder and
calculate its volume
Solution
113
3) Write an algorithm that sums all the even numbers between 1 and 20, and
then displays the sum
Solution
4) Draw flowchart to find the largest among three different numbers entered by
user.
Solution
114
5) Develop the logic of program to check input characters as vowel or consonants.
Solution
115
7) Develop the flowchart that swaps the values in two variables
Solution
116
8) Develop the logic of program to prints out if the number entered is negative
Solution
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
117
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
118
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details
EXPERIMENT 10
Objectives
The purpose of the lab is to get started with the basics of programming language and to get
familiar with debugging the code.
Background
Introduction to C/ C++ Language
C is developed by Dennis Ritchie at AT&T Bell Labs in 1970s which used to maintain UNIX
systems. Many commercial applications are written in C.
119
C++ was developed by Bjarne Stroustrup at AT&T Bell Labs in the 1980s. This overcame
several shortcomings of C. It also incorporated object-oriented programming .C remains a subset
of C++. ‘++’ is an operator in C++.
The Computer Onion
Program Elements
A basic program has following elements:
1) Comments declared as //, /* */
2) Include files
3) Function including exactly one main function
4) Main function contains code or logic of your program being written in programming
language
Variables
• Variables are used to hold values
• The values can be of certain types e.g. it can be numbers, characters etc.
• To hold each value uniquely, each variable is initialized with a data type
For example:
int a = 10;
float b = 0.5;
char c = ‘a’;
120
Figure: 10.2 Basic Program
Output
121
Figure: 10.4 Output
The errors in programming are called bugs. The process of tracking bugs and removing them is
called debugging. Three kinds of errors can occur in a program
1) Syntax Errors
2) Semantic Errors
3) Runtime Errors
1. Syntax Errors: These errors occur when you didn’t follow the syntax of the
programming language. The program will not be compiled if you don’t remove them.
Syntax errors in English language are e.g. Hailo, haow r yeow?
2. Semantic Errors: These are also known as logical errors. The program will compile and
run successfully but it will not do the intended task. This is because there will be an error
in the logic (content) of the program. Debugging logical errors can be tricky because it
requires you to scan the code logically to look for the mistakes. With experience, you will
learn to overcome them easily.
3. Runtime Errors: These errors come at the program execution stage. They are also
known as “Exceptions”. They usually come if the program flow goes out of the expected
order. They are usually rare.
122
Code debugging: It is helpful to detect logical and run time errors from the code. It can also
provide step by step code monitoring. This requires that you add breakpoints at the desired line
of code. Press F11 key to check result at each statement. Press F10 key to execute line of codes
in the current function.
Programming IDE was developed by Microsoft. They used to implement different interactive
software. Visual Studio is an integrated development environment (IDE) that provides a mean to
tell a computer how to do something. Commonly supported languages in VS are: C, C++,
C#.NET and Visual Basic.NET, JavaScript, Python etc.
123
Figure: 10.6 New Project
124
Example
Print “Hello C++ World” in Visual Studio using C++ and debug it
Example
Write a C++ program to take a weighted average of two numbers x1 and x2 such that x1 has 70%
weightage.
Task:
1. Develop a program that takes two numbers and display their multiplication
Solution
2. Develop the logic and write a program that takes the radius and height of a cylinder
and calculate its volume
Solution
125
3. Write a program that sums all the even numbers between 1 and 20, and then
displays the sum.
Solution
126
5. Develop the flowchart that swaps the values in two variables
Solution
127
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
128
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
129
EXPERIMENT 11
Objectives
The purpose of the lab is to get familiar with operators more thoroughly and sharpen the skill of
logic development through visual studio C++ programming.
Background
C++ Operators: An operator is simply a symbol that is used to perform operations. There can be
many types of operations like arithmetic, logical, bitwise etc. There are following types of
operators to perform different types of operations in C language.
1) Arithmetic Operators
2) Relational Operators
3) Logical Operators
4) Bitwise Operators
5) Assignment Operator
6) Unary operator
7) Ternary or Conditional Operator
8) Misc Operator
130
Task:
1. Develop an algorithm and program that takes two numbers and display their
multiplication and sum.
Solution
2. The departmental store manager wants a program that calculates and displays the sale
price of a good when its cost price is entered. Sales price is the final price that has 15%
of GST added to cost price. Develop the logic of this program. Languages Allowed: C+
+
Solution
131
3. Develop an algorithm and then write a program that takes the length, width and height
of a room and calculate its volume and total surface area. Languages: C++
Solution
4. Body mass index (BMI) is a statistical measurement that compares a person’s weight
and height. To calculate BMI, you multiply your weight in pounds by 703 and divide the
result by the square of your height in inches. Develop the logic for a BMI calculator.
Language: C++
Solution
132
5. Develop a program that takes a three-digit number and display the sum of these
numbers. Languages: C++
Solution
133
6. If the marks obtained by a student in five different subjects are input through the
keyboard, write a program to find out the aggregate marks and average marks
obtained by the student. Assume that the maximum marks that can be obtained by a
student in each subject are 100. Take the aggregate sum in ‘int’ and average in float.
Type cast from int to float to take average. Language Allowed: C++
Solution
134
7. Write a program that asks the user to enter a US dollar amount and then shows how to
pay that amount using the smallest number of $20, $10, $5, and $1 bills.
135
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
136
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
137
Conclusions Thorough Good Limited Shows incorrect
understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations
EXPERIMENT 12
Objectives
The purpose of the lab is to get familiar with decision making conditions through the skill of
logic development using visual studio C++ programming.
Background
There come situations in real life when we need to make some decisions and based on these
decisions, we decide what should we do next. Similar situations arise in programming also where
we need to make some decisions and based on these decisions we will execute the next block of
code.
Decision making statements in programming languages decides the direction of flow of program
execution. Decision making statements available in C++ are:
if statement
if-else statements
nested if statements
if-else-if ladder
switch statements
if statement
if statement is the simplest decision-making statement. It is used to decide whether a certain
statement or block of statements will be executed or not i.e. if a certain condition is true then a
block of statement is executed otherwise not.
138
Syntax:
if(condition)
{
// Statements to execute if
// condition is true
}
if(condition)
statement1;
statement2;
Example:
int main()
{
int i = 10;
if (i > 15)
{
cout<<"10 is less than 15";
}
139
}
Output:
I am Not in if
As the condition present in the if statement is false. So, the block below the if statement is not
executed.
if- else
The if statement alone tells us that if a condition is true it will execute a block of statements and
if the condition is false it won’t. But what if we want to do something else if the condition is
false. Here comes the else statement. We can use the else statement with if statement to execute a
block of code when the condition is false.
Syntax:
if (condition)
{
// Executes this block if
// condition is true
}
else
{
// Executes this block if
// condition is false
}
Example:
int main()
{
int i = 20;
140
if (i < 15)
cout<<"i is smaller than 15";
else
cout<<"i is greater than 15";
return 0;
}
Run on IDE
Output:
i is greater than 15
The block of code following the else statement is executed as the condition present in
the if statement is false
Task
1. Write a C++ program to take a number from user and find out whether it is divisible by
3 or not.
Solution
2. Write a program that displays the grade of a student where the marks are input from
the keyboard. The grading pattern is as following:
141
>= 70 A
<40 F
Solution
142
3. Write a program that converts an upper-case letter into a lower-case letter. (Hint: upper
case letter + 32 gives lower case). Language: C++
Solution
143
4. Write a program for a simple calculator. The program should take two float values and
the operation to be performed (char) from the user. The calculator should perform
addition, subtraction, multiplication and division. Example execution
Result: 14.
Solution
144
5. Write a program for an insurance company that allows only people from a certain age
group to be eligible for a specific insurance scheme. If the age is greater than 45 or less
than 25 it says you are not eligible. Else it prints you are eligible. Language: C++
Solution
145
6. The following table shows telephone area codes in the state of Georgia along with the
largest city in each area:
Write a C++ program that inputs the city area code and prints the corresponding city
name.
Solution
146
7. Write a program that determines the wages of a person based on working hours. If a
person works for less than 5 hours his wage per hour is Rs. 400. If he works for more
than 5 and less than 8 hours wage per hour increases to Rs.560. An addition of Rs. 2000
is given as overtime for workers who work up till 12 hours.
Solution
147
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
148
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
149
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details
EXPERIMENT 13
Objectives
The purpose of the lab is to get familiar with decision making conditions through complex
problems using visual studio C++ programming.
Background
nested-if
A nested if is an if statement that is the target of another if statement. Nested if statements mean
an if statement inside another if statement. Yes, C++ allows us to nest if statements within if
statements. i.e., we can place an if statement inside another if statement.
Syntax:
150
if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
}
Example:
// C++ program to illustrate nested-if statement
int main()
{
int i = 10;
if (i == 10)
{
// First if statement
if (i < 15)
cout<<"i is smaller than 15";
// Nested - if statement
// Will only be executed if statement above
// it is true
if (i < 12)
cout<<"i is smaller than 12 too";
else
cout<<"i is greater than 15";
}
return 0;
}
Output:
i is smaller than 15
i is smaller than 12 too
if-else-if ladder
151
Here, a user can decide among multiple options. The if statements are executed from the top
down. As soon as one of the conditions controlling the if is true, the statement associated with
that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then
the final else statement will be executed.
Syntax:
if (condition)
statement;
else if (condition)
statement;
.
.
else
statement;
Example:
// C++ program to illustrate if-else-if ladder
#include<iostream>
using namespace std;
int main()
{
int i = 20;
if (i == 10)
cout<<"i is 10";
else if (i == 15)
cout<<"i is 15";
else if (i == 20)
cout<<"i is 20";
else
cout<<"i is not present";
}
Output:
i is 20
152
dispatch execution to different parts of code based on the value of the expression. Switch is a
control statement that allows a value to change control of execution.
Syntax:
switch (n)
{
case 1: // code to be executed if n = 1;
break;
case 2: // code to be executed if n = 2;
break;
default: // code to be executed if n doesn't match any cases
}
153
Example:
// Following is a simple program to demonstrate
// syntax of switch.
#include <stdio.h>
int main()
{
int x = 2;
switch (x)
{
case 1: printf("Choice is 1");
break;
case 2: printf("Choice is 2");
break;
case 3: printf("Choice is 3");
break;
default: printf("Choice other than 1, 2 and 3");
break;
}
return 0;
}
Output:
Choice is 2
Task
1. Write a program for a simple calculator. The program should take two float values and
the operation to be performed (char) from the user. The calculator should perform
addition, subtraction, multiplication and division. (Use Switch Statements)
Example execution
Enter first number: 4
Enter Second number: 10
Enter operation to be performed (Select from +, -, *, /): +
Result: 14.
Solution
154
2. Write a program to calculate and display the sum of 1 to n in steps of s, where n and s
are numeric-type arguments input from the keyboard such that s denotes the step size
between 1 and n. For example, if n=21 and s=3 are passed, it will display the result of 1
+ 4 + 7 + 10 + 13 + 16 + 19
Solution
155
3. Two numbers x and y are entered through the keyboard. Write a program to find the
value of x raised to the power of y
Solution
156
4. Write a program that asks the user for a two-digit number (i.e. between 10-99), then
prints the English word for the number:
Enter a two-digit number: 45
You enter the number forty-five.
Hint: Break the number into two digits. Use one switch statement to print the word for the
first digit (“twenty”, “thirty”, and so forth). Use a second switch statement to print the word for the
second digit. Don’t forget that the numbers between 11 and 19 require special treatment. This
needs special attention.
Solution
157
5. Use nested loop to print the truth table of three 1-bit inputs
Solution
158
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
159
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
160
life situations situations knowledge.
EXPERIMENT 14
Basics of MATLAB
Objectives
The purpose of the lab is to get familiar with an engineering tool MATLAB. They will be
familiarized with MATLAB interface and its basic features.
Background
MATLAB, which stands for Matrix Laboratory, is a state-of-the-art mathematical software
package, which is used extensively in both academia and industry. It is an interactive program
for numerical computation and data visualization, which along with its programming capabilities
provides a very useful tool for almost all areas of science and engineering
Therefore, learning MATLAB is extremely essential for electrical engineering students.
MATLAB Interface:
161
Figure: 14.1 MATLAB Interface
Command Window − This is the main area where commands can be entered at the command
line. It is indicated by the command prompt (>>).
162
Figure: 14.2 Command Window
Workspace − The workspace shows all the variables created and/or imported from files.
Command History − This panel shows or rerun commands that are entered at the command
line.
163
Figure: 14.4 Command History
Getting Started
If you don’t know anything about MATLAB, then MATLAB help is the best way to learn about
something. In the command window of MATLAB simply write ‘help’;
>> help
It will display list of all toolboxes included in MATLAB. Then by investigating the name of
toolbox or the name of a function, which you would like to learn how to use, use the ‘help’
command:
164
Complex number operations:
Some of the important operations on complex numbers are illustrated below:
Complex scalar >> x = 3+4j
Real part of x >> real(x) = 3
Imaginary part of x >> imag(x) = 4
Magnitude of x >> abs(x) = 5
Angle of x >> angle(x) = 0.9273
Generating Vectors:
Vectors can be generated using the ‘:’ command. For example, to generate a vector x that takes
on the values 0 to 10 in increments of 0.5, type the following, which generates a 1 x 21 matrix?
>> x = [0:0.5:10];
Other ways to generate vectors include the commands: ‘linspace’ which generates a vector by
specifying the first and last number and the number of equally spaced entries between the first
and last number, and ‘logspace’ which is the same except that entries are spaced logarithmically
between the first and last entry.
Accessing Vector Elements:
Specifying the row and column accesses elements of a matrix. For example, in the matrix
specified by A = [1 2 3; 4 5 6; 7 8 9], the element in the first row and third column can be
accessed by following command
>> x = A(1,3) which yields 3
The entire second row can be accessed with
>> y = A(2,:) which yields [4 5 6]
Where the ‘:’ here means “take all the entries in the column”. A sub-matrix of A consisting of
rows 1 and 2 and all three columns is specified by
>> z = A(1:2,1:3) which yields [1 2 3; 4 5 6]
Matrix Operations:
MATLAB contains several arithmetic, relational, and logical operations on matrices.
Arithmetic Operations
The basic arithmetic operations on matrices (and of course scalars, which are special cases of matrices)
are:
165
+ Addition
- Subtraction
* Multiplication
/ Right division
\ Left division
Exponentiation
^
(power)
Con
‘
jugate transpose
An error message occurs if the sizes of matrices are incompatible for the operation. Division is
defined as follows: The solution to A * x = b is x = A\b and the solution to x *A = b is x = b/A
provided A is invertible and all the matrices are compatible.
Addition and subtraction involve element-by-element arithmetic operations; matrix
multiplication and division do not. However, MATLAB provides for element-by-element
operations as well by prep ending a ‘.’ before the operator as follows:
.* Multiplication
./ Right division
.\ Left division
.^ Exponentiation (power)
.‘ Conjugate transpose
166
B = 7 10
15 22
>>C=A.*A
C= 14
9 16
Relational Operations:
The following relational operations are defined:
== Equal to
~= Not equal to
These are element-be-element operations, which return a matrix of ones (1 = true) and zeros
(0 = false). Be careful of the distinction between ‘=’ and ‘= =’.
Flow and control operations:
MATLAB contains the usual set of flow control structures, e.g., for, while, and if, plus the
logical operators, e.g., & (and), | (or), and ~ (not).
Math functions:
MATLAB comes with a large number of built-in functions that operate on matrices on an element-by
element basis. These include:
Sin Sine
Cos Cosine
Tan Tangent
167
Atan inverse tangent
Exp exponential
Sign signum
Task:
1. Run the MATLAB help desk by typing helpdesk. The help desk provides a hypertext
interface to the MATLAB documentation.
Solution
168
2. Use MATLAB as a calculator. Try the following:
pi*pi - 10
sin(pi/4)
ans ˆ 2 %<--- "ans" holds the last result
Solution
169
3. Do variable name assignment in MATLAB. Try the following:
x = sin( pi/5 );
cos( pi/5 ) %<--- assigned to what?
y = sqrt( 1 - x*x )
ans
Solution
170
4. Complex numbers are natural in MATLAB. The basic operations are supported. Try
the following:
z = 3 + 4i, w = -3 + 4j
real(z), imag(z)
abs([z,w]) %<-- Vector constructor
conj(z+w)
angle(z)
Solution
171
172
5. Enter the following in MATLAB.
2 3 1 6
A= ,B=
6 4 6
2
173
Conclusion:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
174
Lab Assessment Rubric
Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.
175
176