Podcast
Questions and Answers
Which command correctly initializes a row vector in MATLAB?
Which command correctly initializes a row vector in MATLAB?
What is the result of the operation g4 = f / g in MATLAB, where f and g are defined as matrices?
What is the result of the operation g4 = f / g in MATLAB, where f and g are defined as matrices?
Which function generates a vector with 10 points equally spaced between -5 and 5?
Which function generates a vector with 10 points equally spaced between -5 and 5?
What is the purpose of the command d2 = randi([-5, 5], 10, 1);?
What is the purpose of the command d2 = randi([-5, 5], 10, 1);?
Signup and view all the answers
Which operator would you use to perform element-wise multiplication of two matrices f and g?
Which operator would you use to perform element-wise multiplication of two matrices f and g?
Signup and view all the answers
To create a column vector with normally distributed random numbers of size 5-by-5 in MATLAB, which command is correct?
To create a column vector with normally distributed random numbers of size 5-by-5 in MATLAB, which command is correct?
Signup and view all the answers
What is the result of the expression h3 = h1 > h2?
What is the result of the expression h3 = h1 > h2?
Signup and view all the answers
Which command would generate a vector of logarithmically spaced numbers between 10 and 100?
Which command would generate a vector of logarithmically spaced numbers between 10 and 100?
Signup and view all the answers
What does the command a2 = [1 2 3 4]; create?
What does the command a2 = [1 2 3 4]; create?
Signup and view all the answers
Which command retains existing plots in the current axes when adding new plots?
Which command retains existing plots in the current axes when adding new plots?
Signup and view all the answers
What does the command 'subplot(m,n,p)' accomplish?
What does the command 'subplot(m,n,p)' accomplish?
Signup and view all the answers
What is the output of the expression h4 = h1 == h2?
What is the output of the expression h4 = h1 == h2?
Signup and view all the answers
What type of plot does the command 'semilogy(x1, y1)' create?
What type of plot does the command 'semilogy(x1, y1)' create?
Signup and view all the answers
Which of the following commands is used to plot data in a log-log scale?
Which of the following commands is used to plot data in a log-log scale?
Signup and view all the answers
What will the result of the operation g7 = f./g be?
What will the result of the operation g7 = f./g be?
Signup and view all the answers
Which operator checks if each element in h1 is less than 2?
Which operator checks if each element in h1 is less than 2?
Signup and view all the answers
Study Notes
Experiment No. 1: MATLAB Basics
- Objective includes defining variables, performing arithmetic operations, and creating vectors/matrices in MATLAB.
- Key operations involve matrix manipulations like transposition, determinant calculation, and matrix inversion.
Software Required
- MATLAB is the primary software used for this experiment.
Basic Commands
Variable Declaration
- Integers: Use
a = 3;
andb = 5;
. - Characters: Use
a1 = "hello";
. - Vectors:
- Row vector:
a2 = [1 2 3 4];
ora21 = [1, 2, 3, 4];
- Column vector:
a3 = [1; 2; 3; 4];
- Row vector:
Defining Vectors
-
linspace(x1, x2, n)
: Generatesn
linearly spaced points betweenx1
andx2
. - Example:
b2 = linspace(-5, 5, 10);
-
logspace
: Generates logarithmically spaced numbers, e.g.,c = logspace(a, b);
- Specify number of values with:
c1 = logspace(a, b, 7);
Random Numbers
- Create a 10x10 matrix of uniformly distributed random numbers using
d = rand(10);
. - Generate 5x5 matrix of normally distributed random numbers with
d1 = randn(5);
. - For uniform integers in
[-5, 5]
:d2 = randi([-5, 5], 10, 1);
.
Matrix Operations
- Initialize matrices with
f = [1 2 3; 4 5 6; 7 8 9];
andg = [1 4 5; 2 5 8; 4 6 3];
. -
Addition:
g1 = f + g;
-
Subtraction:
g2 = f - g;
-
Multiplication:
g3 = f * g;
-
Division:
g4 = f / g;
-
Exponentiation:
g5 = f ^ 2;
-
Element-wise Operations:
-
g6 = f .* g;
(Multiplication) -
g7 = f ./ g;
(Division) -
g8 = f .^ g;
(Exponentiation)
-
Relational and Logical Operators
- Initialize vectors:
h1 = [1 2 3 4 5];
andh2 = [5 4 3 2 1];
-
Greater than:
h3 = h1 > h2;
-
Equal:
h4 = h1 == h2;
-
Less than:
h5 = h1 < h2;
-
Greater than or equal:
h6 = h1 >= 2 & h1 <= 4;
Loops and Conditional Statements
- Basic use of
for
loops andif/else
conditions is fundamental to MATLAB programming.
Data Visualization
- Create 2-D line plots using:
plot(X, Y);
- Multiple plots in one figure with
hold on
for retaining plots. - Open new figures with
figure;
and divide them usingsubplot(m, n, p);
- Plot data sequences with
stem(x, y);
for discrete data representation. - Use semi-logarithmic plots with
semilogy(x1, y1);
and log-log scale plots withloglog(x2, y2);
.
Results & Conclusion
- Students are encouraged to write personal observations and conclusions based on the experiment.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz focuses on using MATLAB for basic operations including defining variables, performing arithmetic, and creating vectors and matrices. It also covers the application of built-in functions for operations like transpose, determinant, and matrix inversion. Perfect for students in Electronics and Communication Engineering.