
In this class we are going to learn what is matlab and why is it so desirable to learn how to use it in nowadays science and engineering niche.
In this class, I wanted you to see exactly what are we going to be able to program as our final project for this module.
Everything that we learn in this module is going to be related (in some way or another) to that final project.
The programming environment is the context in which we build our codes. Matlab offers us a very intuitive way to present us the context in which we will program our applications and this class aims to explain it.
The semicolon as matlab's method of ending a command and why should we use it.
Adding blank spaces between the terms of each command or statement will make your codes more readable, therefore, it is a good practice to do it specially for beginers.
The order of precedence talks about the order in which the operations of a certain statement must be calculated. Just as in its mathematical counterpart, certain operations in matlab take precedence over others, therefore matlab calculates them first. If not understood, we won't be able to do large calculations correctly.
A script is a list of commands that are stored in a file to be executed upon command whenever needed.
Case sensitivity refers to the ability of differentiating between lower case and upper case characters when naming our variables.
Matlab warns us when we command it to calculate or operate something that it is not capable of via errors. It is important that we read carefully the errors that it shows, especially when we are applying things that are new to us.
Functions are self contained pieces of code that take one or several input arguments and throw us one or several output arguments. Self contained means that they make sense on their own, therefore, they can be reused on different matlab applications for they are indifferent to what happens before and after they are called.
Comments are pieces of text within the lines of our code not meant to be read by the computer but by humans. We use comments to explain to another person (or to ourselves in the future) what certain lines of code do.
So far, we have been declaring and using variables without the knowledge that there are several types of variables.
Each type of variable has its own properties and functionalities.
In this class, we are going to learn what are the global variables and the local variables.
Two of the most fundamental inputs in order the allow our codes to interact with the user.
The input command allow us to make our applications ask the user for information whereas the disp (display) command allows us prompt some information to the user via the command window.
The switch case statement is a control mechanism that allows our applications to take one (and just one) decision based on the value of a variable.
We are now ready to handle our final project for this module.
In this class, I wanted you to see exactly what are we going to be able to program as our final project for this module.
Everything that we learn in this module is going to be related (in some way or another) to that final project.
Ploting curves using Matlab will help us understand that machines work iteratively i.e. doing one process at a time. This means that machines do not work on the real of continous numbers but in the discrete mathematics world.
Ploting curves using Matlab will help us understand that machines work iteratively i.e. doing one process at a time. This means that machines do not work on the real of continous numbers but in the discrete mathematics world.
The For loop is a control mechanism that allows a program tu run a set of instructions repeatedly (iteratively) given that we know beforehand how many times will said instructions be repeated. It is one (if not the most) important control statement in any programming language.
The For loop is a control mechanism that allows a program tu run a set of instructions repeatedly (iteratively) given that we know beforehand how many times will said instructions be repeated. It is one (if not the most) important control statement in any programming language.
We will se a realistic and useful application of the for loop on a code to calculate the compound interest of a savings account.
Riemann sums help us approximate definite integrals, but they also help us formally define definite integrals. Learn how this is achieved and how we can move between the representation of area as a definite integral and as a Riemann sum.
Riemann sums help us approximate definite integrals, but they also help us formally define definite integrals. Learn how this is achieved and how we can move between the representation of area as a definite integral and as a Riemann sum.
Riemann sums help us approximate definite integrals, but they also help us formally define definite integrals. Learn how this is achieved and how we can move between the representation of area as a definite integral and as a Riemann sum.
Orange warnings allow us to identify lines in our code that are up to be improved. Whenever Matlab shows us an orange warning It means that, although the code might run and do what we wish, It consumes more time and memory resources than necessary. Normally this is something that we could and should consider solving.
Once a data is ploted, it is important to give it a tittle and labes so it is readable by anyone regardless of if they were involved in the production of the data or not.
Once the plot is created, it is important for us to be able to share it with other engineers or scientists, therefore, we need to be able to save it in order to put it in a report or a presentation.
Doing a screen capture is way too unprofessional and makes your plots blury.
The trapezoid rule is a variant from the Riemann sum in which we aproximate the area under a given curve to the sum of several trapezoids.
In theory and in practice, this method is way more efficient than the previous one in terms of number of calculations needed in order to converge as it manages a lower error on each one.
The trapezoid rule is a variant from the Riemann sum in which we aproximate the area under a given curve to the sum of several trapezoids.
In theory and in practice, this method is way more efficient than the previous one in terms of number of calculations needed in order to converge as it manages a lower error on each one.
As we previously mentioned some videos ago, MATLAB has a lot of nice prebuilt functionalities that any developer can (and should) use for their applications so that they do not have the need of coding well known basic algorithms but code their programs by understanding what to ask the computer to do.
Knowing how to use the prebuilt functions is going to save us a lot of time and will make our codes more prepared to be improved in the future.
In this class, I wanted you to see exactly what are we going to be able to program as our final project for this module.
Everything that we learn in this module is going to be related (in some way or another) to that final project.
In these classes I aim to explain the theory behind the While Loop by directly comparing it against something that we should already be familiar with: The For Loop.
While the For Loop is used (as we saw in the previous module) in order to repeat a set of instructions given that we know beforehand how many times do we want to repeat them, the While Loop is used to repeat instructions WHILE a condition is TRUE. This means that the While Loop while iterate as many times as needed until the condition changes while the For Loop will only do so a give ammount of times.
In these classes I aim to explain the theory behind the While Loop by directly comparing it against something that we should already be familiar with: The For Loop.
While the For Loop is used (as we saw in the previous module) in order to repeat a set of instructions given that we know beforehand how many times do we want to repeat them, the While Loop is used to repeat instructions WHILE a condition is TRUE. This means that the While Loop while iterate as many times as needed until the condition changes while the For Loop will only do so a give ammount of times.
In these classes I aim to explain the theory behind the While Loop by directly comparing it against something that we should already be familiar with: The For Loop.
While the For Loop is used (as we saw in the previous module) in order to repeat a set of instructions given that we know beforehand how many times do we want to repeat them, the While Loop is used to repeat instructions WHILE a condition is TRUE. This means that the While Loop while iterate as many times as needed until the condition changes while the For Loop will only do so a give ammount of times.
The Newton-Rhapson numerical method allows us to find the zeros of any given continuous and derivable mathematical function given an initial guess.
In this video we will learn to understand the logic behind the Newton-Rhapson as a While Loop, for we have to find a better guess on every iterative step while the previous one is not as close to the root as we need it to be.
We will see the concepts of tolerance and numerical derivation.
A function handle is a Matlab data type that stores an association to a function. Indirectly calling a function enables you to invoke the function regardless of where you call it from. Typical uses of function handles include: Passing a function to another function (often called function functions).
Before we implement the newton rhapson method within a while loop in order to automate a solution for any function (i.e. where the function is zero) we will first calculate X(n+1) as a function of X(n) (the previous guess) one iteration at a time so that we can apreciate how the Newton Rhapson gets closer and closer to the solution that is closer to our initial guess.
We will implement our Newton-Rhapson function within a while loop that will re iterate the calculations as long as the function evaluated in our guess is still greter than our allowed tolerace.
This basically means that we will calculate a better solution WHILE the previous on is not close enough to the actual one according to our declared tolerace.
We will know see how sensitive the Newton-Rhapson method is to changes on the initial guess and the allowed tolerance that we ask.
In this lecture we will learn how to safe guard our users from wrongly inputing something to the program that can make it crash in a few lines ahead. We will introduce the if statement that will be studied deeper in the next module as well as the command ''isa'' that basically allows you to get a boolean true if a variable is of the type that you are evaluating and a boolean false atherwise.
As we already know, Matlab offers lots and lots of prebuilt functions that we can use in order to get the results that we need to work with, by arming us with the functions, we can concentrate in the most important parts of our applications instead of wasting time and resources stuffs that are already programmed.
fsolve is another prebuilt function that we can use in order to get the solutions for any function.
In this lecture, we are going to practice the IF - ELSE statement by applying it on a code that determines if a number is odd or even.
IF the remainder of the division by 2 is different from zero, then the number is odd, ELSE the number is an even one.
In order to determine if any given number (A) is prime or not, we need to try to divide it by every number between 2 and the floor (integer part) of square root of A. IF we find any number that entirily divides A, we would have proof that A is not prime.
This algorithm therefore needs to implement an IF statement within a WHILE loop.
As always, we are presenting the results for the final project for this module.
We are going to use the IF - ELSE statement in a Gauss-Jordan matrix inversion function.
The IF-ELSE statement will allow us to decide what to do under certain circumstances in which we may fall.
In this lecture we are going to get the theory behind the Gauss-Jordan algorithm in order to invert a given matrix.
Before we go hands on into our project. We will first practice certain basic matrix operations.
For this module, we are going to be implementing a function capable of making API request to an online service called weatherstack.
API stands for Application Programming Interface. Basically, an API is an online service that offers information upon a request. This requests are often called API calls, and are done via building an HTTP address.
Any time you need some information like financial indicators, weather information, etc, you are very likely to need to implement API requests.
For this module, we are going to be implementing a function capable of making API request to an online service called weatherstack.
API stands for Application Programming Interface. Basically, an API is an online service that offers information upon a request. This requests are often called API calls, and are done via building an HTTP address.
Any time you need some information like financial indicators, weather information, etc, you are very likely to need to implement API requests.
Some API services are free to use and some other ones are paid. Weatherstack offers a free services that, althought very limited in the number of request that may be done on a monthly basis, for all our intents and purposes will sufice.
In order to build the HTTP addresses needed to make the API calls that we want, we need to go throught what's called the API documentation.
Every API service has its own one and it is important to understand what are we going to ask for and how is the answer generated from the other end.
As the API call and request process is a two way process, there's a part of that communication that does not depend at all from the program itself and thus, errors in the running of the program should not be atributed to us, neverhteless, understanding that this may happen forces us to think ahead and consider how to avoid a program to crash.
The TRY - CATCH statement allows us to circumvent hard error without abruptly escaping the program.
If there is not internet, or if the user inputs wrong credentials, the program is unable to know of it until it crashes. Therefore, we, being aware of it, should be able to CATCH those crashing situations.
Most of the times APIs will return information to the programs that we build using JSON files (javaScript oriented notation). Matlab automatically turns this into structure type variables. Thus we need to understand how to extract information out of those types of variables.
While Matlab won't need us to replace blank spaces with ''%20'' on the URLs used to make the API requests. When using addresses with blank spaces on any internet browser, they will automatically replace those blank spaces with ''%20''
Curve fitting is a must know skill for any matlab programmer out there.
Imagine getting a data set and not knowing the mathematical model that describes the physical phenomena that yielded it. Through curve fitting you'll be able to get said mathematical model and thus, you will be able to predict future behaviours.
In this lecture, we are going to set the theory behind the curve fitting process and how do we meassure the goodness of our fit.
As we previously studied in the theoretical part of this module, we need to MINIMIZE the distance that separates our proposed curves from the actual data set in order to get the one that better resembles what we meassured. We are going to be using fminunc in order to do this optimization problem.
The R square is a numerical representation of just how good our fit is, thus, it is very important to show it to the user once we are done with our process.
Programming is ''TALKING'' to a machine in order to let it know what do we want and expect which requires a specific SINTAXIS. Most students get frustrated from not understanding programming because most systems out there do not stop to explain how machines work and ''THINK''. And I know what you are thinking: Machines do not think, do they? Actually no, but they are very ''dumb'' to do things that we take for granted, like counting from 1 to 10, for example. Only by understanding the ins and outs of what is happening inside the ''BRAINS'' of a computer (i.e. how it ''THINKS'') will we be able to adequately ''TALK'' to them. Every concept in this course will be explained and practiced with an example so that we see how the machine is reading what we are telling it to do. By knowing how the machine ''READ'' and interpreted your instructions, SINTAXIS will come as second nature, and you won't need to learn it by memory as you will have understood it.
This course will arm you with everything you need to know to be able to use MATLAB in your college and professional career by the end of it so you can let Matlab be your helpful ally in any kind of statistical, mathematical, engineering or logical task that needs a computer solution.
At the beggining of every module, we will see the exact results of our practical project so that we aim all the concepts that we learn towards it, thus, we will see each and every tool with a goal in mind.