Professional Documents
Culture Documents
Cankaya University
Faculty of Engineering
Mechanical Engineering Department
1-9
keskin
Keskin
KESKIN
Keskin_1
Keskin_2
>> r=8;
>> h=15;
>> V=(pi*r^2*h)/3
V=
1.0053e+03
Numeric
display
formats.
Some commonly used mathematical functions
1-20
abs(z) The absolute value of
z=x+iy
angle(z) the angle of z. This is exa
calculated by atan2(y,x)
Example
Given z=3-5*i
>> real(z)
ans =
3
>> imag(z)
ans =
-5
>> abs(z)
ans =
5.8310
>> angle(z)
ans =
-1.0304
21
25
>> a=30;
>> b=20;
>> A=sqrt(b^2+16*a^2)/2;
>> B=(b^2/( 8*a ))*log((4*a+sqrt(b^2+16*a^2))/b);
>> s=A+B
>>s =
64.9806
COMMENTS
% -the comment symbol
The comment symbol may be put anywhere in the
line. MATLAB ignores everything to the right of the
% symbol. For example,
>> x=3.0;
>> y=3^x;
>> disp(y)
27
Example
Example
>> disp('----------------------------------')
----------------------------------
29
You can perform operations in MATLAB in two ways:
30
Example:
Write a script file for the following
problem and save it as T5
>> T5
Part a
Lp =
92.0412
Part b
m=
7.9057
>> sphere
Enter radius=5
Surface area of sphere
314.1593
Keep in mind when using script files:
39
40
diary
Diary command saves your input to MATLAB and most
of the output to disk. This command toggles diary on and
off. (If no file is given, it is saved to the file diary in the
current directory.)
diary on turns the diary on.
diary off turns the diary off.
41
1)