Video: Detailed Desktop (3.55)

 

 

Transcript

Okay let's understand the desktop layout in a bit more detail. Let's type a simple command, say I want to add two numbers, three and eight. So what will I type? I will type 3 plus 8 and then press enter. What it gives me - Answer is equal to 11. Now what happened to Workspace? Look at the Workspace window - you can see a variable which is named answer and it has value 11. Okay, and what happened to Command history now? So today is 18th of December and what we just type, that command is there. 3 plus 8, Okay? Let's come back to Command Window and do a few more things.

 

Suppose I want to calculate 5 plus 4 and square power 2, okay, so I will type 5 plus 4 squared, this power in MATLAB is ^ 'cap' or 'hat' So you type this and press enter. it will calculate 21. So this is what you expected. 5 plus 4 squared - 4 squared is 16. And 16 plus 5 is 21.


Remember - MATLAB has same order of reference for operations as normal mathematics. So first thing, first priority is bracket and then power, and then multiplication and division and then comes plus and minus. Okay.

So now look at Workspace window. Now you answer variable is replaced by new variable, which is 21. Value has 21. And in Command history there is one more command added. okay, let's come back to Command window. Now, suppose I want to do 5 plus 4 first, and then do the square. What will I do? For that we need to use brackets. It is the same as normal mathematical operations I can recall my previous command using arrow key, up and down arrow key, so I am using up arrow key to get this back. And I now I just want to make bracket here so 5 plus 4 will be evaluated first and then it will be squared. The thing in the bracket will be evaluated first. So after typing this, if I do enter, I got 81. This is what we expected. So 5 plus 4 equals 9 and 9 squared is 81. Okay. now in Workspace, you can see answer is equal to 81 - so it has overwritten previous answer. And in Command history we have another new command added up. Okay? So this is how it works.

Last modified: Monday, 10 August 2015, 10:20 AM