This course teaches computer programming to those with little to no previous experience. It uses the programming system and language called MATLAB to do so because it is easy to learn, versatile and very useful for engineers and other professionals. MATLAB is a special-purpose language that is an excellent choice for writing moderate-size programs that solve problems involving the manipulation of numbers. The design of the language makes it possible to write a powerful program in a few lines. The problems may be relatively complex, while the MATLAB programs that solve them are relatively simple: relative, that is, to the equivalent program written in a general-purpose language, such as C++ or Java. As a result, MATLAB is being used in a wide variety of domains from the natural sciences, through all disciplines of engineering, to finance, and beyond, and it is heavily used in industry. Hence, a solid background in MATLAB is an indispensable skill in today’s job market.
Nevertheless, this course is not a MATLAB tutorial. It is an introductory programming course that uses MATLAB to illustrate general concepts in computer science and programming. Students who successfully complete this course will become familiar with general concepts in computer science, gain an understanding of the general concepts of programming, and obtain a solid foundation in the use of MATLAB.
Students taking the course will get a MATLAB Online license free of charge for the duration of the course. The students are encouraged to consult the eBook that this course is based on. More information about these resources can be found on the Resources menu on the right.

CM

It was a very involving course! Everything is taught by doing it practically. Assignments are really good and make you adept in what you learn the whole week. As far, the Best MOOC I've completed.

RR

Apr 26, 2019

Filled StarFilled StarFilled StarFilled StarFilled Star

This was an amazing course! I attended mainly because I needed to refresh my modest Matlab knowledge. It was a great help and the exercises were so much fun!! Thanks for such a great opportunity!

レッスンから

The MATLAB Environment

We will learn how to start MATLAB and will familiarize ourselves with its user interface. We will learn how to use MATLAB as a sophisticated calculator. We will learn about syntax and semantics. We will see ways in which MATLAB provides help. Finally, we will learn how to create plots in MATLAB.

Akos Ledeczi

Mike Fitzpatrick

字幕

[MUSIC] We've seen that MATLAB's pretty picky about its rules. Every programming language is. The reason is that strict rules make it easier to write accurate, unambiguous programs. We’ve violated MATLAB's rule several times and we've seen these red error messages that they cause. There's a computer science term for this type of rule, the type of rule we've tripped over, it's called syntax. Syntax is a language’s set of rules for the form of the statements, including, for example, the rule that says you can't use a hash symbol in a variable name. Here's another example, one equals x. Of course, MATLAB doesn't like that. As you can see it says that the expression to the left of the equals sign is not a valid target for an assignment. The simple form of this syntax rule, or syntactic rule, that we're violating is this: In an assignment statement there must be a variable name on the left of the equal sign. We knew that, and we know that one is not a variable name. We'll run into lots more syntax areas as we learn more rules. But there's another type of area that is much worse, the semantics error. As we said, the syntax of a command is its form. The semantics of a command is its meaning. An example of semantics is this: Suppose we want to swap the values that are in x and y. First note that the current value of x is 42 and the current value of y is 87. I've seen many new programmers try to do it like this, and by the way, I'm certain I did it too when I was starting out. So they type x equals y, and y equals x. You see what went wrong here? Let's look up here and see that something did go wrong. They're both equal to 87. Instead of having their value swapped, they both now have the value that y had before, so what happened? Well, the first statement, this one here, copied the 87 that was in y into x, and at this point they both have the value 87. So, x's value has just been lost. The 42 is gone. Then this next statement just copies whatever is in x, which happens to be 87 now, back into y. So, y is 87; it was 87; that really didn't do anything. Well let's do it right. First let's set things up the way they were to begin with: x was equal to 42 and y was equal to 87. And we can see that we've done that over here in the Workspace. Now here's how you swap them: temp equals x. We've copied x into temp. temp stands for “temporary variable”. We've actually saved it there, so that when we copy y into x we haven't lost x's value. Now we simply copy temp into y. And there we go. So, when we made the error, MATLAB didn't catch it and it didn't print an error message, And there wasn't any red color. That's because our syntax is perfect. The problem is that our code didn't mean what we thought it did. This is a semantic error, also known as an error of semantics. The semantics of our first try was that y's value was simply copied into x. That's all. It was a semantic error because we thought that x's value would also be copied into y. The semantic error is an error in which the meaning of our code is not what we intended. And the reason that it's worse than a syntactic error is that MATLAB has no way of knowing that it's an error. Neither would the other languages we talked about. We could have made this particular error in any one of thousands of applications because swapping variables is a generic problem that occurs a lot. But an even more common type of semantic error is one that is application specific. Look for example, at the formula we used for calculating absolute zero in degrees Fahrenheit. Right up here. It's correct. But suppose we’d typed this. [MUSIC] Everything’s the same, except that we used a minus instead of a plus. [MUSIC] [APPLAUSE]