Beruflich Dokumente
Kultur Dokumente
09-Feb-13
MATLAB Basics
Overview
MATLAB Desktop Command Window Scripts Practice
MATLAB Basics
09-Feb-13
MATLAB Desktop
Current Folder Workspace Browser The prompt Function Browser
Help Browser
What are the usages of these items? Try it and take notes
MATLAB Basics
09-Feb-13
MATLAB Desktop
Write and calculate simple and complex equations in the command window Observe the workspace browser and the command history. How their contents are affected? Use the help browser then the function browser to learn and to get the square root of a number x.
Command Window
User Input (What you typed) Calculation Results (What MATLAB computed from your statement)
MATLAB Basics
09-Feb-13
Command Window
Use the Up and Down keys while in the command window Double click any line in the command history Add semi-colon at the end of your statement in the command window. Type whos in the command window. What do you get? Type clc in the command window. What happened?
Creating Scripts
Change the current folder to C:\ and observe the Path Browser contents Change the current folder to your FirstLastName folder From MATLAB desktop menu select File New Script Type the following commands in the opened editor Save this file as firstProgram Click the Green Arrow to run these commands Check the output in the command window What is the purpose of this script?
MATLAB Basics
09-Feb-13
Script Contents
a = 1; b = 5; c = 6; d = sqrt(b^2 - 4*a*c); r1 = (-b - d)/(2*a) r2 = (-b + d)/(2*a) Why to use script?
MATLAB Basics
09-Feb-13
Editing Scripts
Go to your FirstLastName folder on Windows desktop Double click to open your firstProgram file Edit this script by adding your name at the beginning of the script. Use % before your name. Why? Re-run the script and see the output at the command window.
Practice
1. Write and execute a script to calculate the area of a rectangle
area=length x width;
2. Write and execute a script to calculate the distance between two points (x1,y1) and (x2,y2)
dist=sqrt((x2-x1)^2+(y2-y1)^2);
3. Write and execute a script to calculate your own equation. (Bonus will be given to good ideas) All scripts should be stored in your FirstLastName folder and have clear names.
MATLAB Basics