KEMBAR78
PD Lab Record | PDF | Microsoft Excel | Microsoft Word
0% found this document useful (0 votes)
55 views82 pages

PD Lab Record

The document provides an overview of Microsoft Word and Excel, detailing their purposes, features, and functionalities. It explains the user interface elements like the Ribbon and various tabs in both applications, along with basic operations and common uses in education and workplaces. Additionally, it highlights essential functions in Excel for data management and analysis, including formulas and chart creation.

Uploaded by

vmaha016
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)
55 views82 pages

PD Lab Record

The document provides an overview of Microsoft Word and Excel, detailing their purposes, features, and functionalities. It explains the user interface elements like the Ribbon and various tabs in both applications, along with basic operations and common uses in education and workplaces. Additionally, it highlights essential functions in Excel for data management and analysis, including formulas and chart creation.

Uploaded by

vmaha016
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/ 82

MS WORD

AIM
The purpose of Microsoft Word documents is to create,
edit, and format text-based documents for various
purposes. Microsoft Word is a widely used word
processing software that provides a range of features
and tools to facilitate the creation and manipulation of
documents.

What is Microsoft Word?


Microsoft Word is word processing software. It is
developed by Microsoft and is part of Microsoft Office
Suite. It enables you to create, edit and save professional
documents like letters and reports.

Ribbon And Tabs


The Ribbon is an user interface element which was first
introduced by Microsoft in Microsoft Office 2007. It is
usually located below the Quick Access Toolbar and the
Title Bar and it comprises seven tabs; Home, Insert,
Page layout, References, Mailing, Review and the View
tab. Each tab has a specific group of related commands
which give you quick access to the commonly used
commands that you need to complete a task.
File Tab
The File tab is a colored tab, for example, a blue tab in
Word, located in the upper-left corner. When you select
the File tab, you see many of the same basic commands
that you saw on the File menu in earlier releases of
Office, such as Open, Save, and Print.

Home tab
The Home tab is the default tab in the Microsoft Word. It
has five subdivided groups of related commands;
Clipboard, Font, Paragraph, Styles and Editing. The
home tab helps you change document settings like font
size, adding bullets, adjusting styles and many other
common features and allows you to return to the home
section of the document.

Insert tab
Insert Tab is the second tab in the Ribbon and as the
name suggests, it is used to insert or add extra features
in your document. It is most commonly used to add
tables, pictures, clip art, shapes, page number, etc. The
Insert tab has seven different groups of related
commands that are Pages, Tables, Illustrations, Links,
Header & Footer, Text and Symbols.

Design tab
The Design tab allows the user to adjust the organization
and visual structure, of the document. The first option to
change in the upper left-hand corner of the tab is a
Design Theme. Clicking on the Themes icon will launch a
drop-down box with a large variety of templates for
document themes.

Layout tab
It allows you to control the look and feel of your
document, i.e., you can easily change the page size,
margins, line spacing, indentation, documentation
orientation, etc. The Page Layout tab has five different
groups of related commands that are Themes, Page
Setup, Page Background, Paragraph and Arrange.

References tab
It allows you to enter document sources, citations,
bibliography commands, etc. It also offers commands for
you to create a table of contents, an index, table of
contents and table of authorities. The References tab has
six different groups of related commands that are Table
of Contents, Footnotes, Citations & Bibliography,
Captions, Index and Table of Authorities.

Mailings tab
It is the fifth tab in this ribbon and probably the least-
often used tab of all the tabs available in this Ribbon. It
allows you merge emails, write and insert different
fields, preview results and convert a file into the PDF
format. The Mailings tab now has five groups of related
commands; Create, Start Mail Merge, Write & Insert
Fields, Preview Results and the Finish command.

Review tab
It offers you some important commands to modify your
document. It also helps you proofread your content, add
or remove comments, track new changes, etc. The
Review tab has a total of six groups of related
commands; Proofing, Comments, Tracking, Changes,
Compare and Protect.
View tab
The View tab is located next to the Review tab and
allows you to switch between Single Page and Two Page
views. It also enables you to control various layout tools
such as boundaries, guides and rulers. Its primary
purpose is to offers you several different ways to view
your document. This tab has five groups of related
commands which are Document Views, Show/Hide,
Zoom, Window and Macros.

Help tab
The Help tab provides access to this help file (Online
Help), which can also be accessed at any time by
pressing the F1 key. In addition, this menu also contains
a number of links to specific important information and
how-to topics in the help and some useful links to the EC
Software website.

Working in Microsoft Word


Use these commands for basic document operations
using Microsoft Word.
To open Word
Say "Open Microsoft Word".
To create a new document
Say "Create New File".
To open an existing document
1. Say "Open File".
2. Dictate the file name. Say "<file name> dot <file
extension>".
3. Say "Press Enter".
To open the File menu
Say "Click File Tab".
To open all other menus:

Say "Click <menu name>".

To select a menu item:

Say "Click <menu option>".

To expand or collapse the ribbon:

Say one of the following:

 "Expand Ribbon"

 "Collapse Ribbon"

To scroll in your document:

Say one of the following:


 "Start Scrolling  "Scroll
Up" Down"

 "Start Scrolling  "Scroll


Down" Faster"

 "Scroll Up"  "Scroll


Slower"

To stop scrolling:

Say "Stop Scrolling".

To move around a document:

Say one of the following:

 "Line Up"

 "Line Down"

 "Page Up"

 "Page Down"

To close a document:

Say "Close File".


To save an existing document:

Say "Save Changes".

To save a new document:

1. Say "Save Changes".


2. Dictate the file name. Say "<filename> dot <file
extension>"

3. Say "Click Save".

To Save As:

1. Say "Save Document As".

2. Dictate the file name. Say "<filename> dot <file


extension>"

3. Say "Save as type"

4. Say "Show choices"

5. Choose the file type by saying "Move down <n>"

6. Say "Press Enter"

7. Say "Click Save".

To print a document:

1. Say "Print Document".

2. Say "Click OK" or "Click Print".

Uses of MS Word
Given below are the different fields in which MS
Word is used and simplifies the work of an
individual:

 In Education: It is considered as one of the


simplest tools which can be used by both teachers
and students. Creating notes is easier using MS
Word as they can be made more interactive by
adding shapes and images. It is also convenient to
make assignments on MS Word and submitting them
online

 In Workplace: Submitting letters, bills, creating


reports, letterheads, sample documents, can all
easily be done using MS Word

 Creating & Updating Resume: One of the best


tools to create your resumes and is easy to edit and
make changes in it as per your experience.
 For Authors: Since separate options are available
for bibliography, table of contents, etc., it is the best
tool which can be used by authors for writing books
and adjusting it as per the layout and alignment of
your choice.

OUTCOME:
In conclusion, MS Word provides several benefits for
academic writing and research projects. It is user-
friendly, provides formatting options, collaboration and
sharing tools, citation and referencing features,
templates, spell and grammar check, auto-save, and ease
of access.

MS EXCEL

AIM
Microsoft Excel enables users to format, organize and
calculate data in a spreadsheet. By organizing data using
software like Excel, data analysts and other users can
make information easier to view as data is added or
changed.

What is MS Excel?
MS Excel is a Microsoft Office application developed by
Microsoft. The Excel Spreadsheet Software supports
multiple operating systems such as Windows, Mac OS,
Android, Ios, and iPad OS. It is used to perform
calculations and computations using various functions
and formulas present in Excel. Users can store and
analyze the data whenever they needed.

Why Should I Learn Microsoft Excel?


We all deal with numbers in one way or the other. We all
have daily expenses which we pay for from the monthly
income that we earn. For one to spend wisely, they will
need to know their income vs. expenditure. Microsoft
Excel comes in handy when we want to record, analyze
and store such numeric data. Let’s illustrate this using
the following image.
Excel ribbon
Microsoft Excel ribbon is the row of tabs and icons at the
top of the Excel window that allows you to quickly find,
understand and use commands for completing a certain
task. It looks like a kind of complex toolbar, which it
actually is.
The ribbon first appeared in Excel 2007 replacing the
traditional toolbars and pull-down menus found in
previous versions. In Excel 2010, Microsoft added the
ability to personalize the ribbon.
The ribbon in Excel is made up of four basic components:
tabs, groups, dialog launchers, and command buttons.
 Ribbon tab contains multiple commands logically
sub-divided into groups.
 Ribbon group is a set of closely related commands
normally performed as part of a larger task.
 Dialog launcher is a small arrow in the lower-right
corner of a group that brings up more related
commands. Dialog launchers appear in groups
that contain more commands than available space.
 Command button is the button you click to
perform a particular action.

Ribbon tabs
The standard Excel ribbon contains the following tabs,
from left to right:
File – allows you to jump into the backstage view that
contains the essential file-related commands and Excel
options. This tab was introduced in Excel 2010 as the
replacement for the Office button in Excel 2007 and the
File menu in earlier versions.
Home – contains the most frequently used commands
such as copying and pasting, sorting and filtering,
formatting, etc.

Insert – is used for adding different objects in a


worksheet such as images, charts, PivotTables,
hyperlinks, special symbols, equations, headers and
footers.

Draw – depending on the device type you're using, it lets


you draw with a digital pen, mouse, or finger. This tab is
available in Excel 2013 and later, but like the Developer
tab it is not visible by default.
Page Layout – provides tools to manage the worksheet
appearance, both onscreen and printed. These tools
control theme settings, gridlines, page margins, object
aligning, and print area.

Formulas – contains tools for inserting functions,


defining names and controlling the calculation options.

Data – holds the commands for managing the worksheet


data as well as connecting to external data.

Review – allows you to check spelling, track changes,


add comments and notes, protect worksheets and
workbooks.

View – provides commands for switching between


worksheet views, freezing panes, viewing and arranging
multiple windows.
Help – only appears in Excel 2019 and Office 365. This
tab provides quick access to the Help Task Pane and
allows you to contact Microsoft support, send feedback,
suggest a feature, and get quick access to training
videos.

Developer – provides access to advanced features such


as VBA macros, ActiveX and Form controls and XML
commands. This tab is hidden by default and you have to
enable it first.

Add-ins – appears only when you open an older


workbook or load an add-in that customizes the tool
View – provides commands for switching between
worksheet views, freezing panes, viewing and arranging
multiple windows.

Contextual Ribbon Tabs


In addition to the constant tabs described above, the
Excel ribbon also has context-sensitive tabs, aka Tool
Tabs, which show up only when you select a certain item
such as a table, chart, shape, or picture. For example, if
you select a chart, the Design and Format tabs will
appear under Chart Tools.

Basic Formula and Operations


1. SUM
The SUM function is the first must-know formula in
Excel. It usually aggregates values from a selection of
columns or rows from your selected range.
=SUM(number1, [number2], …)
Example:
=SUM(B2:G2) – A simple selection that sums the values
of a row.
=SUM(A2:A8) – A simple selection that sums the values
of a column.
=SUM(A2:A7, A9, A12:A15) – A sophisticated
collection that sums values from range A2 to A7, skips
A8, adds A9, jumps A10 and A11, then finally adds from
A12 to A15.
=SUM(A2:A8)/20 – Shows you can also turn your
function into a formula.
2. AVERAGE
The AVERAGE function should remind you of simple
averages of data, such as the average number of
shareholders in a given shareholding pool.
=AVERAGE(number1, [number2], …)
Example:
=AVERAGE(B2:B11) – Shows a simple average, also
similar to (SUM(B2:B11)/10)
3. COUNT
The COUNT function counts all cells in a given range
that contain only numeric values.
=COUNT(value1, [value2], …)
Example:
COUNT(A:A) – Counts all values that are numerical in A
column. However, you must adjust the range inside the
formula to count rows.
COUNT(A1:C1) – Now it can count rows.
4. COUNTA
Like the COUNT function, COUNTA counts all cells in a
given rage. However, it counts all cells regardless of
type. That is, unlike COUNT that only counts numeric, it
also counts dates, times, strings, logical values, errors,
empty string, or text.
=COUNTA(value1, [value2], …)
Example:
COUNTA(C2:C13) – Counts rows 2 to 13 in column C
regardless of type. However, like COUNT, you can’t use
the same formula to count rows. You must make an
adjustment to the selection inside the brackets – for
example, COUNTA(C2:H2) will count columns C to H
5. IF
The IF function is often used when you want to sort your
data according to a given logic. The best part of the IF
formula is that you can embed formulas and functions in
it.
=IF(logical_test, [value_if_true], [value_if_false])
Example:
=IF(C2<D3,“TRUE”,”FALSE”) – Checks if the value at
C3 is less than the value at D3. If the logic is true, let the
cell value be TRUE, otherwise, FALSE
=IF(SUM(C1:C10) > SUM(D1:D10), SUM(C1:C10),
SUM(D1:D10)) – An example of a complex IF
statement. First, it sums C1 to C10 and D1 to D10, then
it compares the sum. If the sum of C1 to C10 is greater
than the sum of D1 to D10, then it makes the value of a
cell equal to the sum of C1 to C10.
6. TRIM
The TRIM function makes sure your functions do not
return errors due to extra spaces in your data. It ensures
that all empty spaces are eliminated. Unlike other
functions that can operate on a range of cells, TRIM only
operates on a single cell. Therefore, it comes with the
downside of adding duplicated data to your spreadsheet.
=TRIM(text)
Example:
TRIM(A2) – Removes empty spaces in the value in cell
A2.
7. MAX & MIN
The MAX and MIN functions help in finding the
maximum number and the minimum number in a range
of values.
=MIN(number1, [number2], …)
Example:
=MIN (B2:C11) – Finds the minimum number between
column B from B2 and column C from C2 to row 11 in
both columns B and C.
=MAX(number1, [number2], …)
Example:
=MAX(B2:C11) – Similarly, it finds the maximum
number between column B from B2 and column C from
C2 to row 11 in both columns B and C.
How to make a pie chart in Excel
Creating a pie chart in Excel is extremely easy, and takes
nothing more than a couple of button clicks. The key
point is to properly arrange the source data in your
worksheet and choose the most suitable pie chart type.
1. Prepare the source data for the pie chart.
Unlike other graphs, Excel pie charts require organizing
the source data in one column or one row. This is
because only one data series can be plotted in a pie
graph.
You can also include a column or row with category
names, which should be the first column or row in the
selection. The category names will appear in the pie
chart legend and/or data labels.
In general, an Excel pie chart looks best when:
 Only one data series is plotted in the chart.
 All data values are greater than zero.
 There are no empty rows or columns.
 There are no more than 7 - 9 data categories,
because too many pie slices can clutter your chart
and make it difficult to understand.
For this Excel chart pie tutorial, we are going to make a
pie graph from the following data:

2. Insert a pie chart in the current worksheet.


As soon as you've arranged your source data properly,
select it, go to the Insert tab and choose the chart type
you want,
In this example, we are creating the most common 2-D
pie chart:

Tip: Include the column or row headings in the selection


if you want the heading of the value column / row to
automatically appear in the title of your pie chart.
3. Choose the pie chart style (optional).
When the new pie chart is inserted in your worksheet,
you may want to go to the Design tab > Charts group,
and try different pie chart styles to choose the one that
works best for your data.
The default pie graph (Style 1) inserted in an Excel 2013
worksheet looks as follows:

Thus, the required pie chart is obtained.

OUTCOME:
Excel is a powerful tool for data management, allowing
you to perform advanced calculations, create graphical
representations of data, and manage real-time
collaboration with others. Mastering Excel can enhance
your efficiency at work, make data organization easier,
and serve as a powerful collaboration tool.
MS POWER POINT

AIM
It is a powerful tool used to create presentations. It
provides everything you need to create a professional
presentation. PowerPoint contains graphic tools and
word processing tools and is easy to use. PowerPoint are
created from a series of slides.
WHAT IS POWERPOINT?
Microsoft PowerPoint is a presentation design
software that is part of Microsoft 365. This software
allows you to design presentations by combining text,
images, graphics, video, and animation on slides in a
simple and intuitive way.
WHAT ARE THE COMPONENTS OF POWERPOINT
WORKSPACE?
PowerPoint Main Window
The first aspect to learn is PowerPoint Main Window. To
facilitate the explanation, we've organized its main
elements with numbers from 1 to 10:
Based on that, the main components of PowerPoint
window are the following:
1. Quick Access Toolbar: allows you to customize
commands to have them at hand. You only have to select
it and go to "More commands."
2. Title Bar: shows you the name of your file. These
options will vary depending on the use you give to the
commands.
3. File Tab: you will see the Home Menu (PowerPoint
backstage) by selecting it. There, you can create a new
presentation, save it, print it, export it, and many other
options.
4. The Ribbon: it's where Power point tabs and tools
are. These tools can also be called "commands" or
“features.”
5. More Button or Down Arrow: these arrows allow
you to view more tools or layout options in PowerPoint.
6. Slides Pane: shows your slides in thumbnail size. By
right-clicking, you can access additional options for
customizing each slide. Perfect for PowerPoint
beginners!
7. Slide: PowerPoint's blank canvas and the frame to be
seen when presenting the file.
8. Placeholders: they are dotted boxes that will store
your content.
9. Status Bar: allows you to view the slide number,
grammatical errors, speaker notes, and the comments on
your file.
10. Zoom: allows you to enlarge or minimize your
PowerPoint workspace. The range goes from 10 to 400%.
POWERPOINT TABS
The PowerPoint tabs are the control desk of your
presentation. Since PowerPoint's features are too many,
they're organized in tabs.
You can come and go between tabs as you need. Once
you click on a tab, it will open its ribbon, and there,
you'll be able to see all the tools related to that
particular category.
 Home Tab
 Insert Tab
 Design Tab
 Transitions Tab
 Animations Tab
 Slide Show Tab
 Review Tab
 View Tab
 Recording Tab
 Help Tab

1. Home Tab
The Home tab is the most common tab of PowerPoint.
This is the tab you'll probably use the most if you're
designing a presentation deck from scratch.

It allows you to add new slides and change the text


characteristics: font, size, boldness, underlining,
alignment, etc. If you've ever used Microsoft Word, these
features will be familiar to you.
Also, you will find commands to edit the
characteristics of the geometric shapes you insert.
This includes: fill color, line color, shape effects, among
others.
2. Insert Tab
The Insert tab is exactly what its name says it is. In this
ribbon, you'll find all the options concerning adding a
new element to your PowerPoint presentation.
You can insert a picture, some geometric shapes, icons,
WordArt graphics, among others.
3. Design Tab
The Design tab offers a wide range of premade
designs, allowing you to get more polished slides. Even
better, if you explore its ribbon, you can adjust the color
palette and change the overall style of your PowerPoint
deck.

4. Transitions Tab
Using transitions in PowerPoint is a dynamic way to
move from one slide to the next during a presentation.

Some PowerPoint transitions are really classic, like


wiping the old slide to present the new one. Others are
somewhat over the top, like the “Vortex” or the
“Airplane” effect.
5. Animations Tab
In case you want to add special effects for certain
elements in your slides, the Animations tab in
PowerPoint will interest you.
Like the Transitions tab, you will find various animation
effects in this ribbon. It's a matter of trying and choosing
the best one according to your needs!
6. Slide Show Tab
As its name says, the Slide Show tab is
about presenting your slides.

7. Review Tab
With this tab, you can check the slide's spelling,
translate the text in real-time, and add comments
to your slides.

8. View Tab
This View tab allows you to change the view of your
PowerPoint slides and make handouts from them,
among other things.

As you can see, the majority of its commands are really


specific. So you won't have any issues while designing,
test and see!
9. Recording Tab
In the last versions of this design presentation software,
PowerPoint added the Recording tab. As its name says, it
allows you to record all your presentation slides.
This ribbon has advanced commands, so the most
common action for a PowerPoint beginner is to take a
screenshot or record the screen sequentially.
10. Help Tab
Finally, there is the Help tab. If you have any problem or
question concerning how to use PowerPoint, you may go
here to look for a solution.
In the latest versions, Windows has added a “Show
Training” option. You can click this command to
practice the PowerPoint basics since it will download
training templates.

POWERPOINT FEATURE

Insert SmartArt
The SmartArt feature lets you create and customize
designer-quality diagrams. You can even convert bulleted
lists into a diagram using the SmartArt diagram tools.
1. Click the Insert tab.
2. Click the SmartArt button on the ribbon.
You can also click the SmartArt icon in a content
placeholder.
3. Select a category.
4. Select a graphic.
A preview and a description appear on the right.
5. Click OK.

The SmartArt graphic is inserted into the presentation.

SmartArt Graphic Types

List Show non-sequential information.

Process Show steps in a process or timeline.

Cycle Show a continual process.


Hierarch Create an organization chart or decision
y tree.

Relations
Illustrate connections.
hip

Matrix Show how parts relate to a whole.

Show proportional relationships with the


Pyramid
largest component on the top or bottom.

Create a SmartArt graphic that


Picture
incorporates pictures.

Insert a chart
Use a chart when you want your audience to easily
understand a large quantity of data and the relationships
between parts of the data. A chart is often much better
at presenting information visually than hard-to-read
numbers in a table.

Chart Types

Column charts are used to compare


different values vertically side-by-side.
Each value is represented in the chart by a
Column
vertical bar.

Line charts are used to illustrate trends


over time. Each value is plotted as a point
on the chart and is connected to the other
Line
values by a line.

Pie charts are useful for showing values as


a percentage of a whole. The values are
Pie represented by different colors.

Bar charts are just like column charts,


except they display information in
Bar horizontal bars rather than in vertical
columns.

Area charts are similar to line charts, but


the area beneath the lines is filled in.
Area
Scatter charts are used to plot clusters of
values using single points. Multiple items
XY(Scatte can be plotted by using different colored
r) points or different symbols.

Stock charts are effective for reporting the


high and low points of stock prices or other
Stock values that tend to fluctuate within a
range.

A surface chart is useful for finding the


best combination of two sets of data.
Surface

Radar charts compare the aggregate


values of a number of data series.
Radar

Combination charts show both a clustered


Combinat column and line chart to compare values
ion and data trends.

Insert an equation
Certain equations are pre-defined because they are used
frequently in algebra and trigonometry, such as
the Pythagorean Theorem and the Quadratic
Formula. The Equation Editor offers to use pre-defined
equations instead of re-creating them.
To insert the equation into the slide, do the following:
1. Do one of the following:
 Select the placeholder or position the cursor in the
text to insert the equation at the specified place.
 Unselect objects on a slide to create a new object for
an equation. Thus, PowerPoint inserts a new text
box in the middle of the slide.
2. On the Insert tab, in the Symbols group, click
the Equation button, and choose one of the equations
from the gallery:

The available predefined equations include:


 Area of Circle,
 Binomial Theorem,
 Expansion of a Sum,
 Fourier Series,
 Pythagorean Theorem,
 Quadratic Formula,
 Taylor Expansion,
 Trig Identity 1,
 Trig Identity 2.
The equation is inserted into the existing text block or
within a new text box on a slide:
OUTCOME:
Identify the names and functions of the PowerPoint
interface, can create, edit, save, print, and add graphic
to a Presentations and can create and manipulate simple
slide shows with outlines and notes.

MATLAB PROGRAMS

ENTER COMMAND
TASK 1:
Multiply the numbers 4 and 2 with the command 4*2
 4*2
 Output: 8

TASK 2:
Assign the result of 4*2 to a variable named m as shown, m=4*2
 m=4*2
 Output: m=8
TASK 3:
Enter the command m=m+1 to see what happens
 m=m+1
 Output: m=9

TASK 4:
Create a variable named y that has the value of m/2
 y=m/2
 Output: y = 4.5

TASK 5:
Enter k=8-2; including the semicolon at the end
 K=8-2;
 Output: k=6

TASK 6:
Edit the command m=4*2 to be m=3*k
 m=3*k
 Output: m=18

TASK 7:
In task 4, you calculated the value of y using the value of m. Recalculated
value of y using modified m in task 6?
 y
 Output: 9
NAME VARIABLES
TASK 1:
Create a variable named A with the value -2
 A= -2
 Output: A= -2

TASK 2:
Use A and a to calculate (a+A)/2. Store the result in a variable named
meanAa
 meanAa = (a+A)/2
 Output: meanAa=3

SAVE AND LOAD VARIABLES


TASK 1:
Save all the variables in the workspace to a file named datafile.net
 Save datafile

TASK 2:
Empty the workspace using the clear command
 Clear

TASK 3:
Load the variables from the file datafile.net
 Load datafile

TASK 4:
Display the contents of the variable data

3.0000 0.5300 4.0753 NaN
Data
18.0000 1.7800 6.6678 2.1328
= 19.0000 0.8600 1.5177 3.6852
20.0000 1.6000 3.6375 8.5389
21.0000 3.0000 4.7243 10.1570
23.0000 6.1100 9.0698 2.8379
38.0000 2.5400 5.3002 4.4508

TASK 5:
Clear the command window using the clc command
 clc
USE BUILT-IN FUNCTIONS AND CONSTANTS
TASK 1:
Create a variable named x with the value of x/2
 x = pi/2
 Output: x=1.5708

TASK 2:
Calculate the sin of x by using the sin function. Assign the result to a
variable named y
 y = sin(x)
 Output: y = 1

TASK 3:
Calculate the square root of -9 by using the sqrt function. Assign the result
to a variable named z
 Z = sqrt(-9)
 Output: Z = 0.0000+3.0000i

THE MATLAB EDITOR


TASK 1:
Enter the command r=3
 r=3
 Output: r = 3
TASK 2:
Add the command x = pi*r^2 to the script
 X = pi*r^2
 Output: x = 28.2743

RUN SCRIPTS
TASK 1:
Modify the command for task 1 so that r has value of 0.5
 r = 0.5
 Output: r = 0.5000

Calculate area:
 x = pi*r^2
 Output: x = 0.7854

DEBUG MATLAB CODE


DATA:
r=3
r=6
TASK:
x = pi**r^2
Navigate to the error by clicking the error icon ( ! ). Then fix the error.
CALCULATE AREA:
 x = pi*r^2
 Output: x = 113.9973
MANUALLY ENTER ARRAYS
TASK 1:
Create a variable named x with a value of 4.
 x=4
 Output: x = 4

TASK 2:
Create an array named y with two elements: 7 and 9
 y = [7 9]
 Output: y = 7 9

TASK 3:
Create an array named z with two elements, 7 and 9 in a single
column by changing the space between them to a semicolon (;)
 z = [7;9]
 Output: z =
7
9

TASK 4:
Create a new vector named a that contains the values 3, 10 and 5 In
that order.
 a = [3 10 5]
 Output: a =
3 10 5

46
TAS

TASK 5:
Create a column vector named b that contains the values 8, 2 and -4
in that order.
 b = [5 6 7; 8 9 10]
 Output: b =
8
2
-4

TASK 6:
Create a matrix named c with these values.
5 6 7
8 9 10

 c = [5 6 7; 8 9 10]
 Output: c =
5 6 7
8 9 10

TASK 7:
Create a row vector named d that contains sqrt(10) as the first
element and pi^2 as the second element.
 d = [sqrt(10) pi^2]
 Output: d =
3.1623 9.8696

47
CREATE EVENLY SPACED VARIABLES
TASK 1:
Create a row vector named x that contains the values 1, 2 and 3 in
that order.
 x = [1 2 3]
 Output: x =
1 2 3

TASK 2:
Create a row vector named y with integer values from 1 to 10, using
the : operator
 y = [1:10]
 Output: y =
1 2 3 4 5 6 7 8 9 10

TASK 3:
Create a new vector named z that starts at 1, ends at 5, with each
element separated by 0.5
 z = [1:0.5:5]
 Output: z =
1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0

TASK 4:
Create a row vector named a that starts at 3 and ends at 13, with
each element spaced by 2.
48
 a = [3:2:13]
 Output: a =
3 5 7 9 11 13

TASK 5:
Create a row vector named b that starts at 1 and ends at 10, and
contains 5 elements
 b = linspace(1,10,5)
 Output: b =
1.0000 3.2500 5.5000 7.7500 10.0000

TASK 6:
Transpose b from a new vector to a column vector using the
transpose operator
 b = b’
 Output: b =
1.0000
3.2500
5.5000
7.7500
10.0000

TASK 7:
In a single command create a column vector named c that starts at 5
and ends at 9, and has elements that are spaced by
 c = (5:2:9)’
 output: c =

49
5
7
9

CREATE ARRAYS WITH FUNCTIONS


TASK 1:
Create a variable named x that is a 5-by-5 matrix of random
numbers.
 x = rand(5)
 Output: x =
0.8147 0.0975 0.1756 0.1419 0.6557
0.9058 0.2785 0.9706 0.4218 0.0357
0.1270 0.5469 0.9572 09157 0.8491
0.9134 0.9575 0.4954 0.7922 0.9340
0.6324 0.9649 0.8003 0.9595 0.6787

TASK 2:
Create a column vector that contains 5 rows and 1 column by the
rand function. Assign the result to a variable named y
 y = rand(5,1)
 Output: y =
0.7577
0.7431
0.3922

50
0.6554
0.1762

TASK 3:
Create a matrix of all zeros that has 6 row and 3 columns by using
the zeros function. Assign the result to a variable named z
 z = zeros(6,3)

Output: z =
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0

INDEX INTO ARRAYS


DATA:
3.0000 0.5300 4.0753 NaN
18.0000 1.7800 6.6678 2.1328
19.0000 0.8600 1.1517 3.6852
20.0000 1.6000 3.6375 8.5389
21.0000 3.0000 4.7243 10.1570
23.0000 6.1100 9.0698 2.8729
38.0000 2.5400 5.3002 4.4508
TASK 1:

51
Create a variable x that contains the values in the 6th row and 3rd
column of the variable data
 x = data(6,3)
 Output: x = 9.0968

TASK 2: Extract the value in the last row and 3rd column of the
variable data by using the end keyword. Assign this value to a
variable named y.
 y = data(end,3)
 Output: y = 5.3002

TASK 3:
Create a variable z that contains the value in the second to last (end-
1) row and 3rd column of the data
 z = data(end-1,3)
 Output: z = 9.0698

EXTRACT MULTIPLE ELEMENTS


DATA
3.0000 0.5300 4.0753 NaN
18.0000 1.7800 6.6678 2.1328
19.0000 0.8600 1.1517 3.6852
20.0000 1.6000 3.6375 8.5389
21.0000 3.0000 4.7243 10.1570
23.0000 6.1100 9.0698 2.8729
38.0000 2.5400 5.3002 4.4508

52
TASK 1:
Create a column vector named density that contains all the elements
of the 2nd column of the matrix named data
 Density = data(:,2)
Output: density =
0.5300
1.7800
0.8600
1.6000
3.0000
6.1100
2.5400
TASK 2:
Create a variable volumes that contains the last two columns of
data.
 volumes = data(:,3:4)
 Output: volumes =
4.0753 NaN
6.6678 2.1328
1.1517 3.6852
3.6375 8.5389
4.7243 10.1570
9.0698 2.8729
5.3002 4.4508

53
TASK 3:
Create a variable named p containing the 6th element of the vector
density
 p = density(6)
 Output: p = 6.1100

TASK 4:
Create a vector named q containing the 2nd through 5th element of
density
 q = density(2:5)
 Output: q =
1.7800
0.8600
1.6000
3.0000

CHANGE VALUES IN ARRAYS


DATA:
3.0000 0.5300 4.0753 NaN
18.0000 1.7800 6.6678 2.1328
19.0000 0.8600 1.1517 3.6852
20.0000 1.6000 3.6375 8.5389
21.0000 3.0000 4.7243 10.1570
23.0000 6.1100 9.0698 2.8729
38.0000 2.5400 5.3002 4.4508
54
TASK 1:
Create a vector named v2 containing the last column of data
 v2 = data(:,end)
 Output: v2 =
NaN
2.1328
3.6852
8.5389
10.1570
2.8729
4.4508

TASK 2:
Change the first element of v2 from NaN to 0.5
 v2(1) = 0.5
 Output: v2 =
0.5000
2.1328
3.6852
8.5389
10.1570
2.8729
4.4508

55
TASK 3:
Change the element in the first row and last column of data to 0.5
 data(1,end) = 0.5
 Output: data =
3.0000 0.5300 4.0753 0.5000
18.0000 1.7800 6.6678 2.1328
19.0000 0.8600 1.1517 3.6852
20.0000 1.6000 3.6375 8.5389
21.0000 3.0000 4.7243 10.1570
23.0000 6.1100 9.0698 2.8729
38.0000 2.5400 5.3002 4.4508

Perform array operations on vectors


DATA:
v1 v2
4.0753 0.5000
6.6678 2.1328
1.5177 3.6852
3.6375 8.5389
4.7243 10.1570
9.0698 2.8739
5.3002 4.4508

TASK 1:

56
Add 1 to each element of v1 and store the result in a variable named
r
 r = 1 + v1
 Output: r =
5.0753
7.6678
2.5177
4.6375
5.7243
10.0698
6.3002

TASK 2:
Create a vector vs that is the sum of the vectors v1 and v2
 vs = v1 + v2
 Output: vs =
4.5753
8.8006
5.2029
12.1764
14.8813
11.9437
9.7510

TASK 3:
Create a variable va that contains the vector vs divided by 2
 va = vs/2
 Output: va=
2.2877
4.4003

57
2.6014
6.0882
7.4406
5.9718
4.8755

TASK 4:
Create a variable vm that contains the maximum of va
 vm = max(va)
 Output: vm = 7.4406

TASK 5:
Using the round function, create a variable named vr that contains
the rounded elements of va
 vr = round(va)
 Output: vr =
2
4
3
6
7
6
5

TASK 6:
Create a variable named mass that contains the element wise
product of density and va
 mass = density.*va
58
 Output: mass =
1.2125
7.8325
2.2372
9.7411
22.3220
36.4880
12.3838

REQUEST MULTIPLE OUTPUTS IN FUNCTION CALLS


TASK 1:
Create a variable named dsize containing the size of the data
variable
 dsize = size(data)
 Output: dsize = 7 4

TASK 2:
Create the variables dr and dc that respectively contains the number
of rows and columns of variable data
 [dr , dc] = size(data)
 Output:
dr = 7
dc = 4

TASK 3:
Create the variables vMax and ivMax containing the maximum
value of the v2 vector and the corresponding index value,
respectively

59
 [vMax, ivMax] = max(v2)
 Output:
vMax = 10.1570
ivMax = 5

DOCUMENTATION
TASK 1:
Create a matrix named x that:
 Contains random integers in the range from 1 to 20
 Has 5 rows
 Has 7 columns

 x = randi(20,5,7)
 Output: x =
17 2 4 3 14 16 15
19 6 20 9 1 15 1
3 11 20 19 17 8 6
19 20 10 16 19 14 1
13 20 17 20 14 4 2

PLOT VECTORS
TASK 1:
Create a plot with sample on the x-axis and mass1 on the y-axis
 plot(sample,mass1)
 Output:

60
TASK 2:
Plot mass2(y-axis) against sample(x-axis). Use red(r) and (*)
markers and no line in your plot
 plot(sample,mass2,”r*”)
 Output:

TASK 3:
Enter the hold on command.
Then plot mass1 against sample with black (k) and square (s)
markers

61
 hold on
 plot(sample,mass1,”ks”)
 Output:

TASK 4:
Enter the hold off command
 hold off
 Output:

TASK 5:

62
Plot the vector v1
 Plot(v1)
 Output:

TASK 6:
Plot v1 with a line width of 3
 plot(v1,”Linewidth”,3)
 Output:

63
TASK 7:
Plot v1 against sample with red and circle markers and a solid line.
Use a line width of 4
 plot(sample,v1,”ro-“,”Linewidth”,4)
 Output:

ANNOTATE PLOTS
TASK 1:
Add the title “Sample Mass” to the plot
 title(“Sample Mass”)
 Output:

64
:

TASK 2:
Add the label “Mass (g)” by using the ylabel function
 ylabel(“Mass (g)”)
 Output:

TASK 3:
Create a legend with the labels “Exp A” and “Exp B”

65
 legend(“Exp A”,”Exp B)
 Output:

IMPORT DATA AS A TABLE


ELEMENTS:
Element Density Volume1 Volume2

1. “Lithium” 0.5300 4.0753 NaN


2 “Argon” 1.7800 6.6678 2.1328
3. “Potassium” 0.8600 1.5177 3.6852
4. “Calcium” 1.6000 3.6375 8.5389
5. “Scandium” 3 4.7243 10.1570
6. “vanadium” 6.1100 9.0698 2.8739
7. “strontium” 2.5400 5.3002 4.4508

66
TASK 1:
Assign the contents of elements.Density to a column vector d
 d = elements.Density
 Output: d =
0.5300
1.7800
0.8600
1.6000
3
6.1100
2.5400

TASK 2:
Multiply each element of elements.Density with elements.volume1.
Assign the result to elements. Mass
 elements.Mass = elements.Density.*elements.Volume1
 Output:

Element Density Volume1 Volume2 Mass

1. “Lithium” 0.5300 4.0753 NaN 2.1599


2 “Argon” 1.7800 6.6678 2.1328 11.8687
3. “Potassium” 0.8600 1.5177 3.6852 1.3052
4. “Calcium” 1.6000 3.6375 8.5389 5.8200
5. “Scandium” 3 4.7243 10.1570 14.1729

67
6. “vanadium” 6.1100 9.0698 2.8739 55.4146
7. “strontium” 2.5400 5.3002 4.4508 13.4626

TASK 3:
Sort the table from the smallest to the largest mass
 Elements = sortrows(elements,”Mass”)
 Output:

Element Density Volume1 Volume2 Mass

1. “Potassium” 0.8600 1.5177 3.6852 1.3052


2 “lithium” 0.5300 4.0753 NaN 2.1599
3. “calcium” 1.6000 3.6375 8.5389 5.8200
4. “Argon” 1.7800 6.6678 2.1328 11.8687
5. “Stromium” 2.5400 5.3002 4.4508 13.4626
6. “scandium” 3 4.7243 10.1570 14.1729
7. “Vanadium” 6.1100 9.0698 2.8739 55.4146

LOGICAL INDEXING
TASK 1:
Test if pi is less than 4 by using the relational operator <. Assign the
output to a variable named x.
 x = pi < 4
 Output: x = logical 1

68
TASK 2:
Test the vector v1 for elements that are less than 4. Assign the output
to a variable named y
 y = v1 < 4
 Output: y =
0
0
1
1
0
0
0

TASK 3:
Create a variable z that contains all the elements of v1 that are less
than 4
 z = v1(v1 < 4)
 Output: z =
1.5177
3.6375

TASK 4:
Create a variable a that contains the elements of sample
corresponding to where v1 is less than 4
 a = sample(v1 < 4)
 Output: a =
19
20

69
TASK 5:
Modify v1 so that any value less than 4 is replaced with the value 0
 v1(v1 < 4)
 Output: v1 =
4.0753
6.6678
0
0
4.7243
9.0698
5.3002

DECISION BRANCHING
TASK 1:
Modify the script so that the plotting code on lines 5-8 exactly only if
doPlot is 1
 If doPlot == 1
plot(density)
title(“Sample Densities”)
xticklabels(element)
ylabel(“Density (g/cm^3)”)
end
 Output:

70
TASK 2:
Modify the script so that when the if condition is not satisfied, this
line of code executes
Disp(“ The density of “ +
element…..
+ “ is ” + density)

 If doPlot == 1
plot(density)
title(“Sample Densities”)
xticklabels(element)
ylabel(“Density (g/cm^3)”)
else
disp(“ The density of “ + element……
+ “ is ” + density)
End

71
 Output:

FOR LOOPS
TASK 1:
Wrap the code on lines 4-5 of the live script in a for loop so that the
code executes 10 times.
Name the loop counter idx. For the first execution of loop, idx
should have a value of 1, and it should increase by 1 in each
consecutive iteration
 hold on
for idx = 1:10
plot(idx, density(idx),”*”)
drawnow
end
hold off

72
 Output:

STELLAR MOTION
DATA
nObs = 357
lambdaStart = 630.020
lambdaDelta = .1400
TASK 1:
Create a variable named lambdaEnd that contains the value of last
wavelength I the reorded spectrum. You can calculate lambdaEnd
with the expression
λstart+(nObs−1)λdelta.
 lambaEnd = lambdaStart + (nObs – 1) * lambdaDelta
lambda = (lambdaStart : lambdaDelta : lambdaEnd)
 Output: lambdaEnd = 679.0200
lambda =

73
630.020 630.160 630.300 630.440
630.580…….

TASK 2:
Extract the sixth column of spectra to a vector named s
 s = spectra(: , 6)
 Output: s = 10^-12 *
0.1625
0.1630
0.1615
0.1586
0.1574
0.1589
0.1611
0.1607
0.1593
0.1582

TASK 3:
Plot the spectra as a function of wavelength. Use point markers and
a solid line to connect the points
 plot(lambda,s,”.-“)
 xlabel(“Wavelength”)
 ylabel(“Intensity”)
 Output:
74
TASK 4:
Create two variables, sHa and idx, that contain the minimum value
of s and the index of that minimum value
 [sHa, idx] = min(s)
 lambdaHa = lambda(idx)
 Output: sHa = 9.8010e-14
idx = 191
lambdaHa = 656.6200

TASK 5:
Add a point to the existing axes by plotting x=lambdaHa, y=sHa as a
red square (“rs”) with a marker size of 8
 hold on
 plot(lambda,sHa,”rs”,”MarkerSize”,8)

75
 Output:

TASK 6:
Calculate the red shift factor and the speed at which the star is
moving away from the earth. Assign the red shift factor to a variable
named z and the speed to a variable named speed

 z = lambdaHa/656.28 – 1
 Speed = z*299792.458
 Output: z = 5.1807e-04
Speed = 155.3139

COMPARE STELLAR SPECTRA


TASK 1:
Modify line 2 of the script. Calculate the speed of all the stars by
deleting (:,2)
76
 [sHa , idx] = min(spectra);
 lambdaHa = lambda(idx);
 z = lambdaHa/656.28 -1;
 speed = z*299792.458

77
 Output: speed =
-36.5445
-100.4973
-36.5445
27.4083
27.4083
155.3139
-228.4029

TASK 2:
Create a for loop with a loop index named v. The loop index should
progress through all columns of spectra
 for v = 1:7
s = spectra(:,V);
end
 Output:
10^-12* 10^-12* 10^-13* 10^-13* 10^-12* 10^-12* 10^-
13*
0.3088 0.1340 0.5981 0.8919 0.1088 0.1625
0.3918
0.3136 0.1338 0.6074 0.9152 0.1084 0.1630
0.3821
0.3105 0.1357 0.6176 0.9311 0.1104 0.1615
0.3712
0.3076 0.1354 0.6252 0.9355 0.1124 0.1586
0.3776

78
0.3088 0.1343 0.6271 0.9321 0.1122 0.1574
0.3910
0.3105 0.1335 0.6221 0.9286 0.1136 0.1589
0.3955
0.3122 0.1325 0.6249 0.9240 0.1138 0.1611
0.4023
: : : : : :
:

TASK 3:
Add an if statement to the for loop body. If speed is less than or equal to
0. Create a plot of s against lambda using a dashed line. Add the
command hold on between the two end keywords.
 for v = 1:7
S = spectra(:,v);
If speed(v) <= 0
Plot(lambda,s,”--”)
end
hold on
end
 Output:

79
TASK 4:
Add an else statement. If speed is greater than 0, create a plot of s
against lambda using a line width of 3. After the for loop enter the
hold off command.
 for v = 1:7
s = spectra(:,v);
if speed(v) <= 0
plot(lambda,s,”--”)
else
plot(lambda,s,”LineWidth”,3)
end
hold on
end
hold off
 Output:

80
TASK 5:
Add a legend to the plot by using the array starnames
 Legend(starnames)
 Output:

TASK 6:

81
Create a variable movaway that contains the elements in starnames
corresponding to where speed is greater than 0
 Movaway = starnames(speed > 0)
 Output: movaway =
“HD 5211”
“HD 56030”
“HD 94028”

Result :
Thus all the Codings of MATLAB Onramp was executed and the
output was obtained successfully.

82

You might also like