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 will discuss MATLAB's built-in functions, which you will frequently use for computations. Can anyone tell me some of the basic mathematical operations we can perform?
We can calculate trigonometric values like sine and cosine!
Exactly! Functions like sin(x) and cos(x) are built into MATLAB. Remember, these are called built-ins. Another important one is the exponential function, denoted as exp(x). Who can explain what this does?
It computes e raised to the power of x!
Correct! And when calculating with these, be cautious about variable assignment. Why do we need to be careful?
Because we shouldn't overwrite the built-in functions!
Right! Using names like ii or jj for loop indices can help prevent confusion. Let's move on to specific examples next.
Let's take an example of calculating y = exp(-a)*sin(x)+10*sqrt(y}. If I assign a = 5, x = 2, and y = 8, can anyone work this out?
We need to first compute exp(-5) and sin(2)!
Exactly! After calculating these values, don’t forget to add 10 * sqrt(8}.
I have it! The result for y is approximately 28.29.
Well done! Now, let's look at logarithmic functions. Who can explain the difference between log(x) and log10(x)?
log(x) is the natural logarithm, and log10(x) is the base-10 logarithm!
Exactly! Understanding these functions is crucial because they are widely used across various fields.
To exemplify further, let's calculate sin(pi/4) and compare it to exp(10). What results do we expect?
I think sin(pi/4) should be around 0.7071.
Correct! And exp(10) will give us a much larger number. Let’s actually run these in MATLAB.
I want to see how the outputs are different!
Absolutely! And remember, when you use commands like these, ensure your input variables are correct to avoid errors in your calculations.
We should also remember not to overwrite MATLAB's built-in functions. It can be confusing!
Great summary! Always keep your variable names distinct to keep things clear.
To remember sin and cos real well, angles in radians are what they tell.
Imagine e as a balloon that grows exponentially, just like our math problems.
For logs, just think Base is best! to remember the difference between base logarithms.
E.L.S. - Exponential, Logarithmic, Sine - to remember the three main functions we use.
Term
How do you calculate the sine of an angle in MATLAB?
Click to flip
Term
What does `exp(x)` do?
Click to flip
Predefined functions in MATLAB for performing mathematical calculations.
The function exp(x) computes e raised to the power of x.
The logarithm function, with log(x) indicating the natural logarithm and log10(x) for logarithm base 10.
A trigonometric function to calculate the sine of an angle in radians.
This section illustrates typical examples using MATLAB's built-in mathematical functions to enhance understanding.
The section provides hands-on examples of using MATLAB's built-in mathematical functions and calculations. Various expressions are computed, showcasing the functionality and differences between functions like natural logarithm and common logarithm, as well as basic operations involving exponential functions.
In this section, we explore practical examples of using MATLAB's predefined mathematical functions. These functions simplify technical computing by allowing users to perform complex calculations with ease. We begin by calculating the value of mathematical expressions step-by-step, including the use of the exponential function, sine function, and logarithmic functions with specific variables assigned. For instance, we computed the expression y = exp(-a)*sin(x) + 10*sqrt(y) for given values of a, x, and y, demonstrating the application of built-in functions. Moreover, we highlight the distinctions between the natural logarithm (log) and the decimal logarithm (log10), ensuring clarity in their usage. The section also includes an example of computing sin(pi/4) and exp(10). Finally, we finish with reminders on function usage best practices, emphasizing not to reassign values to built-in functions.