MATLAB functions

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What does 'surfaced' mean, according to the notes?

  • To become submerged
  • To make something smooth
  • To make something extremely heavy
  • To obey a rule or law (correct)

What does 'maintained' mean?

  • To discard something
  • To forget about something
  • To check infrequently
  • To keep something in good working order (correct)

What is meant by 'moderation'?

  • To listen carefully
  • To give something away freely
  • To be the opposite of something
  • To control your behaviour (correct)

What does 'stopping' mean?

<p>Stopping by your actions or habits (A)</p> Signup and view all the answers

According to the notes, what does 'obesity' refer to?

<p>Common at a particular group of ppl (D)</p> Signup and view all the answers

What does the term 'struggle' mean?

<p>You are trying extremely hard. (A)</p> Signup and view all the answers

What does 'unqualified' suggest?

<p>Complete and total (D)</p> Signup and view all the answers

What does 'maintenance' involve?

<p>Repairs that are necessary (B)</p> Signup and view all the answers

What does 'beaming at' mean?

<p>To be smiling (B)</p> Signup and view all the answers

What is the meaning of 'to beam'?

<p>To transmit or broadcast something (C)</p> Signup and view all the answers

What is the meaning of 'smirking'?

<p>Smiling in an unpleasant way (D)</p> Signup and view all the answers

What does 'perking up' mean?

<p>To make someone cheerful (A)</p> Signup and view all the answers

What does 'incivility' refer to?

<p>Impolite behavior (A)</p> Signup and view all the answers

What does 'gloom' represent?

<p>Complete darkness and sadness (A)</p> Signup and view all the answers

What best describes 'starker'?

<p>Impossible to avoid (A)</p> Signup and view all the answers

What does 'intended' refer to?

<p>A situation that is difficult or unpleasant (A)</p> Signup and view all the answers

What is the meaning of 'wake up to something'?

<p>To be short to realize (B)</p> Signup and view all the answers

What does 'keeping up to' mean?

<p>To seem less important (B)</p> Signup and view all the answers

What is the definition of 'affluent'?

<p>Boastful or showy (C)</p> Signup and view all the answers

What does the phrase 'jump-start' mean?

<p>To help a process or activity to start (D)</p> Signup and view all the answers

Flashcards

Surfaced

Amount to equals

Enforcing

To make people obey a rule or law

Maintained

Keep in good condition by checking and repairing it regularly

Seeking to

Trying to achieve or get

Signup and view all the flashcards

A handful of

Very small amount of something

Signup and view all the flashcards

Run counter to

To be the opposite of something

Signup and view all the flashcards

Moderation

Controlling your behaviour

Signup and view all the flashcards

Staggering

Extremely big or surprising

Signup and view all the flashcards

Prevalent

Common at a particular time; place/among particular group of people

Signup and view all the flashcards

Struggle

Trying extremely hard knowing you're likely to fail

Signup and view all the flashcards

Unqualified

Complete/total

Signup and view all the flashcards

Maintenance

Repairs that are necessary to keep something in good condition

Signup and view all the flashcards

Joviality

Friendly and happy

Signup and view all the flashcards

Beaming out

To transmit/broadcast something

Signup and view all the flashcards

Smirking

Smiling in an unpleasant way/weary or ragged period

Signup and view all the flashcards

Gloom

complete darkness/ great sadness and lack of hope

Signup and view all the flashcards

Starker

Impossible to avoid

Signup and view all the flashcards

Wretched lot

Ungrateful person

Signup and view all the flashcards

Wake up to sth

Short to realize

Signup and view all the flashcards

Affluent

Bogaty

Signup and view all the flashcards

Study Notes

Functions in MATLAB

  • Functions are blocks of code designed for specific tasks, aiding in program complexity management.
  • MATLAB offers built-in functions like sqrt, sin, and plot, and allows users to create custom functions.

Anatomy of a Function

  • The function declaration starts with the keyword function.
  • Output arguments are variables returned by the function, enclosed in square brackets [] (optional for single output).
  • The function name should be descriptive and follow MATLAB conventions.
  • Input arguments are values received by the function, enclosed in parentheses ().
  • Comments describing the function are displayed with the help command.
  • Statements are MATLAB commands executing the function's task.
  • Function definition concludes with the keyword end.

Example: Circle Area Function

  • A function to calculate the area of a circle takes the radius as input.
  • It calculates area as area = pi * radius^2;.
  • The function is saved in a file named circle_area.m and called from the command window or script.

Branching and Loops

  • if statements, for loops, and while loops can be incorporated to create functions that adapt based on input or repeat actions.

Simulations

  • Simulations are computer programs that model real-world systems.
  • Systems too complex or dangerous for direct experimentation can be studied using these.

Simple Function: Fahrenheit to Kelvin

  • fahr_to_kelvin converts temperature from Fahrenheit (temp_F) to Kelvin (temp_K).
  • The conversion formula is $T_K = (T_F - 32) \times \frac{5}{9} + 273.15$.

Number of Days in a Month

  • days_in_month calculates days in a given month using an integer input from 1 to 12.
  • An if statement determines the number of days based on the month. Months 1, 3, 5, 7, 8, 10, and 12 have 31 days; 4, 6, 9, and 11 have 30 days; and 2 has 28 days (non-leap year).

Projectile Trajectory Simulation

  • projectile_trajectory simulates a projectile's path, influenced by gravity.
  • Inputs: initial speed v0 (m/s), launch angle theta (degrees), time step dt (s).
  • Outputs: vectors x and y for coordinates, and t for time values.
  • Convert theta to radians.
  • Calculate initial x and y velocities (v0x and v0y) using v0 and theta.
  • Initialize x and y coordinates to zero.
  • Update position in a while loop at each time step.
  • Update x coordinate using $x = v_{0x} \times t$.
  • Update y coordinate using $y = v_{0y} \times t - \frac{1}{2} \times g \times t^2$ ($g = 9.81 m/s^2$).
  • Stop when y becomes negative (projectile hits ground).
  • Plot the trajectory where y is plotted against x, creating a display of the projectile's flight path over time.

Modifying Projectile Trajectory for Air Resistance

  • The projectile_trajectory function is updated to incorporate air resistance.
  • Air resistance is proportional to the square of the projectile's velocity: $F_D = \frac{1}{2} \times C_D \times \rho \times A \times v^2$
  • New inputs: drag coefficient CD, cross-sectional area A. Air density $\rho$ is $1.225 kg/m^3$.
  • Update x and y velocities at each time step with air resistance.
  • $F_{Dx} = F_D \times \cos(\theta)$ and $F_{Dy} = F_D \times \sin(\theta)$.
  • $a_x = \frac{F_{Dx}}{m}$ and $a_y = -g + \frac{F_{Dy}}{m}$ where m is mass (kg) and g is $9.81 m/s^2$.
  • Update velocities: $v_x = v_x + a_x \times dt$ and $v_y = v_y + a_y \times dt$.
  • Plot trajectory with and without air resistance on the same graph.

Linear Algebra

Definition of Vectors

  • Vectors are ordered lists of numerical values.
  • They are represented as column matrices: $\vec{a} = \begin{bmatrix} a_1 \ a_2 \ \vdots \ a_n \end{bmatrix}$.
  • The $a_i$s are components, and $n$ is the vector space dimension.

Vector Operations

  • Given vectors $\vec{a}$ and $\vec{b}$ of dimension $n$, and scalar $c$:
    • Addition: $\vec{a} + \vec{b} = \begin{bmatrix} a_1 + b_1 \ a_2 + b_2 \ \vdots \ a_n + b_n \end{bmatrix}$
    • Scalar Multiplication: $c \cdot \vec{a} = \begin{bmatrix} c \cdot a_1 \ c \cdot a_2 \ \vdots \ c \cdot a_n \end{bmatrix}$

Dot Product

  • For vectors $\vec{a}$ and $\vec{b}$ of dimension $n$:
    • $\vec{a} \cdot \vec{b} = a_1b_1 + a_2b_2 + \dots + a_nb_n = \sum_{i=1}^{n} a_i b_i$

Vector Norms

  • Euclidean Norm (L2 Norm): $||\vec{a}||2 = \sqrt{a_1^2 + a_2^2 + \dots + a_n^2} = \sqrt{\sum{i=1}^{n} a_i^2}$
  • Manhattan Norm (L1 Norm): $||\vec{a}||1 = |a_1| + |a_2| + \dots + |a_n| = \sum{i=1}^{n} |a_i|$

Definition of Matrices

  • Matrices are rectangular arrays of numbers, symbols, or expressions, arranged in rows and columns.
  • They are represented as: $A = \begin{bmatrix} a_{11} & a_{12} & \dots & a_{1n} \ a_{21} & a_{22} & \dots & a_{2n} \ \vdots & \vdots & \ddots & \vdots \ a_{m1} & a_{m2} & \dots & a_{mn} \end{bmatrix}$.
  • $a_{ij}$ is the element in the $i$-th row and $j$-th column. $m$ is the number of rows, and $n$ is the number of columns.

Matrix Operations

  • Given matrices $A$ and $B$ of compatible dimensions and a scalar $c$:
    • Addition: For $m \times n$ matrices $A$ and $B$, $(A + B){ij} = A{ij} + B_{ij}$.
    • Scalar Multiplication: $(cA){ij} = c \cdot A{ij}$.
    • Matrix Multiplication: For matrix $A$ ($m \times n$) and matrix $B$ ($n \times p$), $(AB){ij} = \sum{k=1}^{n} A_{ik} B_{kj}$

Special Matrices

  • Identity Matrix: A square matrix with ones on the main diagonal and zeros elsewhere, denoted as $I$.
  • Transpose of a Matrix: The transpose of matrix $A$, denoted as $A^T$, is obtained by interchanging rows and columns, such that $(A^T){ij} = A{ji}$.

Matrix Properties

  • Commutative Property: For addition, $A + B = B + A$.
  • Associative Property: For addition, $(A + B) + C = A + (B + C)$. For multiplication, $(AB)C = A(BC)$.
  • Distributive Property: $A(B + C) = AB + AC$ and $(A + B)C = AC + BC$.

System of Linear Equations

  • A set of linear equations can be represented as:
    • $\begin{cases} a_{11}x_1 + a_{12}x_2 + \dots + a_{1n}x_n = b_1 \ a_{21}x_1 + a_{22}x_2 + \dots + a_{2n}x_n = b_2 \ \vdots \ a_{m1}x_1 + a_{m2}x_2 + \dots + a_{mn}x_n = b_m \end{cases}$

Matrix Representation

  • The system of linear equations can be represented in matrix form as: $Ax = b$.
    • $A$ is the coefficient matrix.
    • $x$ is the vector of variables.
    • $b$ is the vector of constants.

Solving Linear equations

  • Gaussian Elimination: Solving linear equations by transforming the augmented matrix into row-echelon form or reduced row-echelon form.
  • Inverse Matrix Method: If A is invertible, the solution to $Ax = b$ is $x = A^{-1}b$.

Definition of Eigenvalues and Eigenvectors

  • Given a square matrix $A$, the eigenvector $\vec{v}$ and its corresponding eigenvalue $\lambda$ satisfy: $A\vec{v} = \lambda\vec{v}$. $\vec{v}$ is a non-zero vector and $\lambda$ is a scalar.

Characteristic Equation

  • For finding eigenvalues, one must solve the characteristic equation: $\text{det}(A - \lambda I) = 0$, where $I$ is the identity matrix and $\text{det}$ is the determinant.

Properties of Eigenvalues/Eigenvectors

  • The sum of the eigenvalues equals the trace of matrix $A$.
  • The product of the eigenvalues equals the determinant of matrix $A$.

Applications of Linear Algebra

  • Linear Regression: Used to solve problems, finding the best-fit line or hyperplane for data points.
  • Principal Component Analysis (PCA): A dimensionality reduction technique that uses eigenvectors to find the principal data components of the data.
  • Image Processing: Matrices represent images and linear algebra techniques are applied for transformations, filtering, and compression.
  • Graph Theory: Adjacency and incidence matrices represent graphs. Analyzing graph properties utilizes linear algebra techniques.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Like This

MATLAB Basic Functions - Std Quiz
30 questions
MATLAB Array and String Functions
10 questions

MATLAB Array and String Functions

OptimisticComposite7871 avatar
OptimisticComposite7871
MATLAB: Functions, Vectors, and Equations
5 questions
Use Quizgecko on...
Browser
Browser