Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we are here to explore the built-in mathematical functions available in MATLAB. These functions simplify technical computations significantly. Can anyone tell me what some basic mathematical operations are?
Are functions like sine and cosine included?
What about exponential and logarithmic functions?
Absolutely! Functions such as sin(x), cos(x), and exp(x) are some examples of MATLAB's powerful offerings. Remember, we can categorize these as 'elementary functions' and they are very useful in engineering and physics.
How do we find these functions in MATLAB?
Good question! You can type help elfun for elementary functions and help specfun for special functions. Let's remember this by the acronym 'EFS' for Easy Function Search!
That’s helpful! What about the mathematical constants?
Great point! Constants like π and the imaginary unit are also built-in. For example, pi gives you the value of π directly in MATLAB.
To summarize, today we learned about key built-in functions, how to access them, and discussed some important constants like π. Next, let’s look at examples.
Now that we've reviewed the basics, let's explore some examples. For instance, calculating y = exp(-a)*sin(x) + 10*sqrt(y). Any idea how we can do this?
We would first set values for a, x, and y, right?
Correct! Let’s code that in MATLAB. For example, setting a = 5, x = 2, and y = 8 and executing it gives us an output of approximately 28.2904. Remember that this reinforces the concept that we can handle various numerical data types like scalars, vectors, and even matrices in MATLAB.
What happens when we want to compute the logarithm?
Good question! MATLAB has two types: the natural logarithm log(x) and the base-10 logarithm log10(x). For example, if you type log(142), you get about 4.9558; for log10(142), it's 2.1523.
So they are not the same!
Exactly! Understanding this will help you choose the right function based on your calculations. To wrap up, we practiced some essential computations and learned about varying logarithmic functions.
Before we conclude our lesson, let’s talk about some common pitfalls when using MATLAB functions. Can anyone guess what might be a mistake?
Maybe it’s reassigning built-in function names?
Yes! Reassigning a function could lead to unforeseen errors. Stick with the original names for built-in functions like i and j in MATLAB as they are preset for imaginary values. It’s better to use ii or jj as loop indices.
What if I accidentally overwrite them? What happens?
That's a critical error! To avoid confusion in your code, always keep built-in functions intact. Just remember the phrase 'Keep Built-ins Clean'!
Thanks for the tips! It sounds like following this will save me from headaches down the road.
Definitely! In summary, we highlighted essential practices when using MATLAB functions to help you avoid common mistakes. Now, let's move on to some quick exercises.
For sin and cosine, use sin and cos, In MATLAB they perform without a pause.
Imagine you are a wizard, casting spells with numbers. With sin(x) and cos(x), make waves dance on the water!
Remember 'ECL' for Elementary Functions: Exponential, Cosine, Logarithm.
Use 'BIE': Built-in, Important, Efficient when recalling fundamental functions.
Term
MATLAB Command for Cosine
Click to flip
Term
Natural Logarithm Function
Click to flip
Term
Base 10 Logarithm Function
Click to flip
Term
Exponential Function
Click to flip
Term
Square Root Function
Click to flip
Predefined functions in MATLAB that perform specific mathematical operations.
Basic mathematical functions such as sine, cosine, and exponential that can be directly used in MATLAB.
Standard fixed values such as π and i (the imaginary unit) that are readily available in MATLAB.
The inverse operation to exponentiation, returning the exponent as a result.
This section provides an overview of the mathematical functions available in MATLAB, highlighting their application in technical computing.
MATLAB offers a rich library of predefined mathematical functions essential for technical computing, including elementary functions and constants. The section emphasizes how functions like trigonometric, logarithmic, and exponential operations can be performed and provides examples for clarity.
MATLAB serves as a powerful tool for technical computing, equipped with a wide array of predefined mathematical functions. This section discusses the significance of built-in functions, such as trigonometric functions like sin(x), cos(x), and exponential functions like exp(x). Furthermore, it presents handy tables listing elementary functions and constants, such as π and the imaginary unit. Readers are guided through examples that illustrate how to compute complex mathematical expressions, enhancing their understanding of MATLAB's capabilities in handling both simple and advanced calculations.