Beruflich Dokumente
Kultur Dokumente
Solution.
x=-5+9i;
y=6-2i;
z=x+y
t=x*y
u=x/y
z =1.0000 + 7.0000i
t = -12.0000 +64.0000i
u = -1.2000 + 1.1000i
Solution.
type the following lines of code into the editor.
x=6*(351/4)+(140^0.35)
The output of this program is given bellow.
x =532.1383
t=0:0.5:5;
s=2*sin(3*t+2)+sqrt(5*t+1)
plot(t,s)
title('Speed');
xlabel('time');
ylabel('speed');
LAB No 2
1- e^-t,
2- e^-2t.
3- -e^-2t.
&
also plot the functions
(e^-t - e^-2t)
Solution.
Code for the above program is as follows.
syms x y z t
t=0:.05:5;
x=exp(-t);
plot(x)
grid on
xlabel('t')
ylabel('Amp')
title('exp(-t)')
subplot(2,2,1)
y=exp(-2*t)
plot(y)
grid on
xlabel('t')
ylabel('Amp')
title('exp(-2*t)')
subplot(2,2,2),
z=-exp(-2*t)
plot(z),
grid on
xlabel('t')
ylabel('Amp')
title('-exp(-2*t)')
subplot(2,2,3)
q=exp(-t);
w=-exp(-2*t);
e=q+w;
plot(e)
grid on
xlabel('t')
ylabel('Amp')
title('exp(-t)-exp(-2*t)')
subplot(2,2,4)
LAB No:3
x = 1:0.1:3;
T = 6*log(t)-7*(exp .2*t);
plot (x,T);
title(‘Temperature in celcius’);
ylabel(‘Y axis’’);
xlabel(‘x axis’’);
Select the ‘File -> Save’ menu of the editor, and save the file by
the name of‘firstprog’. Now, close the Editor.
LAB No.4
Solution.
X=[-2:0.1:6];
For k =1:length(x)
If x(k) <-1
Y(k) = exp(x(k)+10;
elseif x(k)=2+cos(pi*x(k)<5
Y(k)=10*(x(k));
else y(k)=10*10(x(k)-5)+1;
end
end
plot(x,y);
xlabel(‘x-time in seconds’)
ylabel(‘y-hight in kello meters’)
Q.No.2: Write a script file to determine how many
terms are required for the sum
of the series 5k2 - 2k, k =1,2,3,….. to exceed
10,000. What is the sum for this many
terms?
Solution:
Because we do not know how many times we must evaluate the
expression
5k2 – 2k, we use a while loop. The script file is the following:
clc;
clear;
total = 0;
k = 0;
while total < 1e+4
k=k+1;
total = 5*k^2 – 2*k + total;
end
disp(‘The number of terms is:’)
disp(k)
disp(‘The sum is: ‘)
disp(total)