1. Assignment # 1
Fall 2015
Course title: STRUCTURED COMPUTER PROGRAMMING Course #: EE201
Sections: All
Name: Student #:
Start MATLAB by either double clicking over the MATLAB icon on your desktop, or by selecting: Start menu → ALL Programs → MATLAB.
You will at least 4 windows inside MATLAB; Command Window, Workspace, Current Folder and Command History.
If you don’t see them all, click on Layout and select Default, as shown below:
Khaled Mohammed Ali AL-awlaqi 1324593
2. Q1) In MATLAB command window, type the following:
>> x = 2.5
>> y = 2.5;
>> A = [ 1 3 5 7]
>> B = [ 2; 4; 6; 8]
>> M = [ 1 3 5 7; 2 4 6 8]
What is the effect of the semicolon?
Q2) Write the suitable MATLAB help command to find out how to use the following symbols and functions in MATLAB:
Mathematical operation
Matlab help command
√푎
×
푎푏
sin−1(푥)
|푦|
Hint: help is used when you know the Matlab function and lookfor is used when you don’t know the Matlab function for the given operation.
For example: help sin
lookfor cosine x=2.5 store and display y = 2.5; store but don't display A = [ 1 3 5 7] store and display B = [ 2; 4; 6; 8] store but don't display M = [ 1 3 5 7; 2 4 6 8]store but don't display
lookfor power
lookfor multiply
sqrt
asin
abs
3. Q3) Use MATLAB to compute the following mathematical expressions:
Mathematical Expression
MATLAB form
Result
푞= 2휋−5.4√3+√73
푎= log10(123)− −34+12⁄
푊=1.5; 푟= cos−1푊+90√|2푊−푊2|
푧= tan23휋 23+cos60°
푘= 푐+푎 푏 푏+2푎 +푐
Where a = 4; b = 5; c = -2;
푚=104×ln푒√33
푥=1;푦= −2 푛= sin(휋푥)22+푦2푥
4+7푖 √|9−3푖|
>>q=(2*pi-5.4)/sqrt(3)+7^(1/3)
>>w=1.5;
>> r=(acos(w)+90)/sqrt(abs(2*w-w^2))
>> a=log10(12^3)-(-3/4+(1/2))
>> z=(tan(3*pi/2))^2/3+cosd(60)
m=10^4*log(exp(sqrt(33)))
>>a=4;
>> b=5;
>> c=-2;
>> k=(c+a)/b/(b+2*a)+c
>>x=1;
>> y=-2;
>> n=sin(pi*x)^2/(2+y^(2*x))
>> b=(4+7i)/sqrt(abs(9-3i))