0% found this document useful (0 votes)
3 views3 pages

ICM Lab Experiment 2

The document outlines an experiment focused on fundamental MATLAB programming concepts, including directory navigation, array manipulation, logical indexing, and graphical output. It details the tools required, theoretical concepts, practical exercises, and observations related to using MATLAB. Additionally, it emphasizes the importance of understanding relational and logical operators, as well as the significance of plotting and saving graphical outputs.

Uploaded by

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

ICM Lab Experiment 2

The document outlines an experiment focused on fundamental MATLAB programming concepts, including directory navigation, array manipulation, logical indexing, and graphical output. It details the tools required, theoretical concepts, practical exercises, and observations related to using MATLAB. Additionally, it emphasizes the importance of understanding relational and logical operators, as well as the significance of plotting and saving graphical outputs.

Uploaded by

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

Experiment 2

Introduction to Directory Navigation, Concatenation, Indexing,


Logical Indexing, Modification and Saving Graphical Output
Aim: To understand and implement fundamental MATLAB programming concepts, including
directory navigation, concatenation, indexing, relational and logical operators, logical
indexing, modification of array, plotting, and generating graphical output.

Tools Required: MATLAB Desktop or MATLAB online


Theory:
1. Navigating Directory

Explain the purpose and usage of the following commands:

• what:
• cd:
• pwd:
• type:
• mkdir:
• edit:

2. Generating Random Numbers


What are the applications of random numbers?
How can we generate 3x4 matrix having uniformly distributed random numbers
between 0 and 1?
How can we generate 2x2 matrix having normally distributed random numbers?
Additionally, how can we generate random integer numbers between two given values
[take any two values] with a desired size [take any size like 2x3]?

3. Concatenation of Arrays:
How to join two vectors in one row or in one column or in a form of matrix (both vectors
act as two rows OR two columns).
How to join matrices.

4. Index and Indexing:


• Define what an index is and how indexing works in MATLAB.
• Make a vector and matrix then perform the following operation:
▪ Extract, modify, and delete elements from a vector.
▪ Extract an element, submatrix, entire row, or entire column from a matrix.
▪ Use the end keyword to access the last row or column of a matrix.

5. Relational and Logical Operators:


▪ Describe the following relational operators and their meanings:
o == (equal to), < (less than), > (greater than), <= (less than or equal to),
>= (greater than or equal to), ~= (not equal to).

▪ Explain how to combine conditions using logical operators:


o & (AND), | (OR).

6. Logical Indexing:
• Define logical indexing and its purpose.
• Make a vector and write a short code to:
o Find the number of elements greater than a threshold (take any value)
using logical indexing.
o Modify those elements that greater than a threshold using logical
indexing.

7. Plotting:
• Explain how to create a plot when two vectors x and y are given by writing a
short program to demonstrate:
o Adding a title to the plot.
o Changing the x and y limits.
o Adding x and y labels.
o Changing the fonts size
o Plotting two graphs on the same figure.
o Adding legends to distinguish between plots.

8. Taking Graphical Output:

Explain how to save a plot using the exportgraphics function.

Schematic Diagram/Code Output: You can paste your plot here.


Procedure/Code: you can write one or two working MATLAB Code related to indexing
and plots. OR write these codes in the relevant sections/headings.

9. Observations:
Write your observations about MATLAB based on your experience in this experiment. For
example:

• Is it possible to expand matrices based on earlier matrices available in the


workspace?
• How does logical indexing simplify complex problems?
• How useful are relational operators for specifying conditions?
• Is plotting useful for visualizing large datasets? Can plots be annotated?

10. Important Points


Write some important points to remember and what you learned from the experiment. e.g:

• What precautions should you take while joining two matrices together? Describe the
conditions required to concatenate two matrices (e.g., compatible dimensions).
• Why is it important to save plots?
• How can logical indexing and relational operators improve code efficiency?

References:
1. MATLAB Documentation
2. MATLAB Functions
3. MATLAB Operators and Special Characters
4. Array Indexing
5. Matrix Indexing in MATLAB
6. Plot

You might also like