0% found this document useful (0 votes)
14 views6 pages

Labno 1

The document contains 11 lab tasks involving generating and plotting various vectors and functions in MATLAB. Task 1 generates a vector from 60 to 70 in increments of 0.1. Task 2 defines and performs operations on matrices. Subsequent tasks involve plotting functions like sine waves, exponentials, and polynomials using vectors defined in the tasks. The final task plots cosine and polynomial vectors on different subplots and combines them on a subplot spanning the lower half of the figure.

Uploaded by

vowtipegg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

Labno 1

The document contains 11 lab tasks involving generating and plotting various vectors and functions in MATLAB. Task 1 generates a vector from 60 to 70 in increments of 0.1. Task 2 defines and performs operations on matrices. Subsequent tasks involve plotting functions like sine waves, exponentials, and polynomials using vectors defined in the tasks. The final task plots cosine and polynomial vectors on different subplots and combines them on a subplot spanning the lower half of the figure.

Uploaded by

vowtipegg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lab tasks:

1. B=[60:0.1:70]

Answer:
B=

Columns 1 through 8

60.0000 60.1000 60.2000 60.3000 60.4000 60.5000 60.6000 60.7000

Columns 9 through 16

60.8000 60.9000 61.0000 61.1000 61.2000 61.3000 61.4000 61.5000

Columns 17 through 24

61.6000 61.7000 61.8000 61.9000 62.0000 62.1000 62.2000 62.3000

Columns 25 through 32

62.4000 62.5000 62.6000 62.7000 62.8000 62.9000 63.0000 63.1000

Columns 33 through 40

63.2000 63.3000 63.4000 63.5000 63.6000 63.7000 63.8000 63.9000

Columns 41 through 48 64.0000 64.1000 64.2000 64.3000 64.4000 64.5000 64.6000 64.7000

Columns 49 through 56

64.8000 64.9000 65.0000 65.1000 65.2000 65.3000 65.4000 65.5000

Columns 57 through 64

65.6000 65.7000 65.8000 65.9000 66.0000 66.1000 66.2000 66.3000

Columns 65 through 72

66.4000 66.5000 66.6000 66.7000 66.8000 66.9000 67.0000 67.1000

Columns 73 through 80

67.2000 67.3000 67.4000 67.5000 67.6000 67.7000 67.8000 67.9000

Columns 81 through 88

68.0000 68.1000 68.2000 68.3000 68.4000 68.5000 68.6000 68.7000


Columns 89 through 96

68.8000 68.9000 69.0000 69.1000 69.2000 69.3000 69.4000 69.5000

Columns 97 through 101

69.6000 69.7000 69.8000 69.9000 70.0000

2. V=[3 3 3;4 4 4;5 5 5] 3. H=[2 3 4 6;5 4 3 5;6 7 8 3;8 7 4 8]

G=[3 5 6;3 8 9;9 5 4] Ans;

Y= V*G H=

Ans; 2 3 4 6

V= 5 4 3 5

3 3 3 6 7 8 3

4 4 4 8 7 4 8

5 5 5

G= 4. K=eye(3)

3 5 6 ans;

3 8 9 K=

9 5 4 1 0 0

Y= 0 1 0

45 54 57 0 0 1

60 72 76

75 90 95

5. X=abs(k) 6. Y=sin t/t,0<t<5

Sol:x =1 0 0 sol: t=0:0.005:5;


0 1 0 y=sin(t)./t;
0 0 1 plot(t,y);
xlabel('Time');
ylabel('amplitude');
title('sink function');
7.y=Acos(2nft),where 0<t<5,f=1,A=10 8.y=e^2t,0<t<5

Sol; A=10; sol; t=0:0.005:5;


f=1; y=exp(2*t);
plot(t,y);
t=0:0.005:5; xlabel('Time');
y=A*cos(2*pi*f*t); ylabel('Amplitude');
plot(t,y); title('Exponention');
xlabel('Time');
ylabel('Amplitude');
title('Cos funtion');
grid on

9.

>> roots_p=roots([2, 3, 1]);

roots_q=roots([1, -5, 6]);

product=conv([2, 3, 1],[1, -5, 6]);

p_minus1=polyval([1, -5, 6],6);

p_derivative=polyder([2, 3, 1]);

q_derivative=polyder([1, -5, 6]);


>> roots_p

roots_p =

-1.0000

-0.5000

>> roots_q

roots_q =

3.0000

2.0000

>> product

product =

2 -7 -2 13 6

>> p_minus1

p_minus1 =

12

>> p_derivative

p_derivative =

4 3

>> q_derivate

Undefined function or variable 'q_derivate'.

>> q_derivative

q_derivative =

2 -5

10.Create a figure divided into four subplots.Plot the


eight sine waves and title each subplot.

Sol: y1=sin(x);

>> y2=sin(2*x);
>> y3=sin(4*x);

>> y4=sin(8*x);

>> subplot(2,2,1)

>> plot(x,y1)

>> title('subplot 1:sin(x)')

>> subplot(2,2,2)

>> plot(x,y2)

>> title('subplot 2:sin(2x)')

>> subplot(2,2,3)

>> plot(x,y3)

>> title('subplot:3:sin(4x)')

>> subplot(2,2,4)

>> plot(x,y4)

>> title('subplot 4:sin(8x)')

11.Define a vector of cos values and a vector of polynomial values.Plot the polynomial in the first
subplot and cos wave in the second subplot.Create a third subplot that spans the lower half of the figure
and plot both vectors together.

Sol: x=linspace(-3.8,3.8);

>> y_cos=cos(x);

>> y_poly=1-x.^2./2+x.^4./24;

>> subplot(2,2,1);

>> plot(x,y_cos);

>> title('Subplot 1:Cosine')

>> subplot(2,2,2);

>> plot(x,y_poly,'g');
>> title('Subplot 2:polynomial')

>> subplot(2,2,[3,4]);

>> plot(x,y_cos,'b',x,y_poly,'g');

>> title('Subplot 3 and 4:both')

You might also like