0% found this document useful (0 votes)
7 views2 pages

Experiment 1 1

The document outlines an introductory experiment on MATLAB, covering basic commands, variable assignment, array initialization, and prebuilt functions. Key topics include element-wise operations, displaying values, and creating magic squares. The conclusion highlights the author's positive experience and the foundational knowledge gained for future MATLAB projects.

Uploaded by

manthanpatel0808
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)
7 views2 pages

Experiment 1 1

The document outlines an introductory experiment on MATLAB, covering basic commands, variable assignment, array initialization, and prebuilt functions. Key topics include element-wise operations, displaying values, and creating magic squares. The conclusion highlights the author's positive experience and the foundational knowledge gained for future MATLAB projects.

Uploaded by

manthanpatel0808
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/ 2

Digital Signal Processing – 20IC210P

Experiment 1
Aim: Introduction to MATLAB
Theory:
1. Assigning value to a variable: We can assign value to any variable using the
‘=’ symbol.
Syntax: a=5; OR a=5
If you omit the semicolon at the end of a command, the result is displayed
immediately in the command window.

2. Initializing an
array: In MATLAB, an array is
a fundamental data structure that can store
values of the same type. Arrays can be one-
dimensional (like vectors) or multi-dimensional
(like matrices). Initializing an array involves
allocating space for the array and assigning
values to its elements.
Syntax:
a=[1,2,5,6,7]  Row Vector
b=[2;4;3;8;9]  Column Vector
c=[1, 2; 3, 4]  Matrix

3. Prebuilt Functions:
3.1.Zeros: Creates an array of zeros.
3.2.Ones: Creates an array of ones.
3.3.Rand: Creates an array with random values
between 0 and 1.
Syntax:
a=zeros(3,3)
b=ones(3,2)
c=rand(2,3)

4. Displaying: The ‘disp’ function in MATLAB is


used to display the value of a variable or a
string of text in the command window. It is a simple and effective way to
output information without displaying the variable name or any additional
text.
Syntax:
disp(a);
disp(‘Hello MATLAB’);

Prerita Shukla – 23BIT119 1


Digital Signal Processing – 20IC210P

5. Element-wise Operator: To
multiply each element of an array
individually in MATLAB, you can
use element-wise multiplication.
The element-wise multiplication
operator is (.*).
Same is applicable for all other
logical operators as well.
Syntax:
a=[1,2,5,6,7]
b=[2,4,3,8,9]
c=a.^2+b.*3

6. Assigning a range of values to a


variable: The colon operator is a
simple and efficient way to create
arrays with a specified range and
step size.
Syntax:
t=0:2
t=0:1:5

7. Length: The length function in


MATLAB returns the length of the
largest array dimension. It's a simple
yet useful function to determine the
size of a vector or the maximum
dimension of a matrix.
Syntax: N=length(t)

8. Magic: The magic function in


MATLAB creates a magic square. A
magic square is a matrix in which
the sum of the elements in each
row, column, and the main
diagonals are all the same. This sum
is known as the magic constant.
Syntax: y=magic(5)

Conclusion: This experiment gave me a solid introduction to MATLAB. I learned


about its user interface, basic commands, and functions, and got hands-on
experience with data visualization and matrix operations. MATLAB's ability to
simplify complex computations was impressive, and I can see how it can be a
powerful tool in various fields. This experiment has set a strong foundation for
me to continue exploring and using MATLAB in my future projects.

Prerita Shukla – 23BIT119 2

You might also like