Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Introduction to Taif University

Computer Programming Faculty of Engineering


803213-3 Electrical Engineering Dept.
Exercise Sheet #2 Fall 2017

1. Write MATLAB commands to solve each of the following problems:

g e−0.05 t−1
a. Find the value of the expression
k
t+ ( k )
, where k =0.05, g=9.81

and t=3
k=0.05; g=9.81; t=3;
f = g / k * (t +(exp(-0.05*t)-1)/k)

b. Find the average of two numbers x 1=7 and x 2=19.


x1=7; x2=19;
a = (x1+x2)/2

c. Find the average of a set of five numbers {9,12,23,44,57}


x=[9 12 23 44 57];
a = mean(x)
OR
a = mean( [9 12 23 44 57] )

d. Calculate the area of a circle of radius is 3.5 m


r=3.5;
a = pi*r^2

e. Calculate how long it takes a car traveling at a given uniform speed of


120 km/ hour to travel a distance of 450 km.

v=120; d=450;
t=d/v

2. Use MATLAB help to find suitable built-in functions and write MATLAB
commands to perform the following tasks:

1
a. Find the absolute (positive) value of −5
abs(-5)

b. Approximate the number 9.25 to the nearest integer.


round(9.25)

c. Find the remainder of dividing 517 by 7


rem(517, 7)

d. Calculate the time t taken by a particle to hit the ground if it was

stationary at height d=100m and started falling freely under


1 2
gravitational acceleration of g=9.8 m/s 2 (Hint d= 2 g t )

d = 100; g = 9.8;
t = sqrt(2*d/g)

You might also like