Professional Documents
Culture Documents
Practical Lecture 1 Final PDF
Practical Lecture 1 Final PDF
SCHOOL OF ENGINEERING
DEPARTMENT OF MECHATRONICS ENGINEERING
Prepared by: Eng. Rasha Noufal
Computer Programming for Engineers/ MATLAB
Practice/assignment. 1
Focus of this week: General introduction to MATALB. The goal of this session is to become
familiar with MATLAB screen and perform simple tasks using MATLAB, such as generating an
arrays and matrices, define variables, and finding roots of a function, making a simple plot.
The commands to be entered in MATLAB screen are bolded
>> a=5*2
>> a=5*2; ( Notice the difference between this line and the previous line)
>> a=7+8/2
>> a=(7+8)/2
>> a=4+5/3+2
>> a=5^3/2
>> a=27^(1/3)+32^0.2
>>x=2;
>>y=2;
>>R=(y+5)*x
>>clc
>>R
>>clear R (clears the variable R from MATLAB)
>>R
>>pi
>>5/0
>>0/0
>> a=0.7854-(0.7854)^3/(1*2*3)+0.785^5/(1*2*3*4*5)…
-(0.785)^7/(1*2*3*4*5*6*7)
Problem 2 : complete the table below
Problem 3 :
1. Calculate:
2. Suppose that X=2 and y =5. Use MATLAB to compute the following
Problem. 4: Vector variables and arrays : Make the following variables
Use MATLAB to find the roots of 13 x3 + 182x2 ‐184x + 2503 = 0.
.
Problem. 9 : plot the function 3.5 cos 6 2 4.
Problem. 10: Plotting a function and its derivatives Plot the function 3 26 10. and its
first and second derivatives, for 2 4 , all in the same plot
Problem. 12: A cylindrical silo with radius r has a spherical
cap roof with radius R. The height of
the cylindrical portion is H. Write a program
in a script file that determines the
height H for given values of r, R, and the
volume V. In addition, the program calculates
the surface area of the silo.
Use the program to calculate the height and
surface area of a silo with r = 30 ft, R = 45
ft, and a volume of 120,000 ft3. Assign values
for r, R, and V in the Command Window.
Vcyl = πr2H
Which h 1
Using the equations above, the height, H, of the cylindrical part can be expressed by
The surface area of the silo is obtained by adding the surface areas of the cylindrical part and the
spherical cap.