Signals & Systems Lab Experiment 1
16 Questions
0 Views

Signals & Systems Lab Experiment 1

Created by
@RichParody

Questions and Answers

Which command correctly initializes a row vector in MATLAB?

  • a = [1 2 3 4]; (correct)
  • a = (1, 2, 3, 4);
  • a = {1, 2, 3, 4};
  • a = [1; 2; 3; 4];
  • What is the result of the operation g4 = f / g in MATLAB, where f and g are defined as matrices?

  • Matrix division using the right division operator. (correct)
  • Element-wise division of f and g.
  • Transpose of matrix g.
  • Matrix multiplication of f and g.
  • Which function generates a vector with 10 points equally spaced between -5 and 5?

  • b2 = logspace(-5, 5, 10);
  • b2 = linspace(-5, 5, 10); (correct)
  • b2 = range(-5, 5, 10);
  • b2 = rand(-5, 5, 10);
  • What is the purpose of the command d2 = randi([-5, 5], 10, 1);?

    <p>Generate a 10-by-1 vector of uniformly distributed random integers.</p> Signup and view all the answers

    Which operator would you use to perform element-wise multiplication of two matrices f and g?

    <p>g3 = f . * g;</p> 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?

    <p>d1 = randn(5, 5);</p> Signup and view all the answers

    What is the result of the expression h3 = h1 > h2?

    <p>[1 1 1 0 0]</p> Signup and view all the answers

    Which command would generate a vector of logarithmically spaced numbers between 10 and 100?

    <p>c = logspace(1, 2, 5);</p> Signup and view all the answers

    What does the command a2 = [1 2 3 4]; create?

    <p>A row vector.</p> Signup and view all the answers

    Which command retains existing plots in the current axes when adding new plots?

    <p>hold on</p> Signup and view all the answers

    What does the command 'subplot(m,n,p)' accomplish?

    <p>Divides the current figure into multiple plots</p> Signup and view all the answers

    What is the output of the expression h4 = h1 == h2?

    <p>[0 1 0 1 0]</p> Signup and view all the answers

    What type of plot does the command 'semilogy(x1, y1)' create?

    <p>Semi-logarithmic plot with a logarithmic scale on the Y-axis</p> Signup and view all the answers

    Which of the following commands is used to plot data in a log-log scale?

    <p>Loglog(x2, y2)</p> Signup and view all the answers

    What will the result of the operation g7 = f./g be?

    <p>Element-wise division of f by g</p> Signup and view all the answers

    Which operator checks if each element in h1 is less than 2?

    <p>h5 = h1 &lt; 2</p> 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; and b = 5;.
    • Characters: Use a1 = "hello";.
    • Vectors:
      • Row vector: a2 = [1 2 3 4]; or a21 = [1, 2, 3, 4];
      • Column vector: a3 = [1; 2; 3; 4];

    Defining Vectors

    • linspace(x1, x2, n): Generates n linearly spaced points between x1 and x2.
    • 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]; and g = [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]; and h2 = [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 and if/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 using subplot(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 with loglog(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.

    Quiz Team

    Related Documents

    SnS_Lab_Exp_1.pdf

    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.

    More Quizzes Like This

    Use Quizgecko on...
    Browser
    Browser