Professional Documents
Culture Documents
NYK Matlab Coursework 1
NYK Matlab Coursework 1
1) y=sin(x)
2) y=1/x
10
0.5
-0.5
-5
3) y=exp(-x.(2))
1
0.8
0.6
0.4
-1
20
40
radian
60
4) y=(((exp(x))-(exp(-x)))/2)
-10
-10
300
200
100
-100
-1
-200
-2
-300
20
40
radian
60
0.2
-3
radian
10
5) y=log(x+sqrt((x.2)+1))
20
40
radian
60
Question 2.
a=270
b=140
c=1200
a=input('Whatisthevalueofa?/n')
b=input('Whatisthevalueofb?/n')
c=input('Whatisthevalueofc?/n')
z1=((bsqrt(b^24*a*c))/(2*a))
z2=((bsqrt(b^24*a*c))/(2*a))
disp('')
disp('z1=');disp(z1);
disp('z2=');disp(z2);
disp('')
fprintf('Realpartofz1is%f',real(z1));
fprintf('Imaginarypartofz1is%f\n',imag(z1));
fprintf('Absolutevalueofz1is%f\n'abs(z1));
fprintf('Arguementofz1is%f\n'angle(z1);
fprintf('Realpartofz2is%f',real(z2));
fprintf('Imaginarypartofz2is%f\n',imag(z2));
fprintf('Absolutevalueofz2is%f\n'abs(z2));
fprintf('Arguementofz2is%f\n'angle(z2);
Question 3.
Eo=8.85418782*(10^12)
Mo=4*pi*10^7
Er=[1:12]
c=sqrt(1./(Er*Eo*Mo))
plot(Er,c)
title('EragainstSpeedoflight')
xlabel('m*s^1')
ylabel('arbitaryunit')
20
40
radian
60
10
2.5
arbitary unit
1.5
0.5
10
12
m*s- 1
Question 4.
%1clear
commandtodeletethevariablesintheworkspace
%2figure
%3xlabel
commandtolabelthexaxis
%4plot
commandtosketchgraphofthedataoffirstvariableagainstthedataof
secondvariable
%5surf
Question 5.
A=randi(8,8)%1
B=zeros(8,8)%2
D=ones(8)%3
D(logical(eye(size(D))))=0
E=A;E(:,4)=B(:,4)%4
F=transpose(A)%5
Z=round(rand(5)*2010)%6
T=diag(ones(5,1))%7
G=Z*T%8
H=Z.^(T*2)%9
R=[Z;T]%10
Question 6.