0% found this document useful (0 votes)
20 views4 pages

Solution Sheet2

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

Solution Sheet2

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

Solution: sheet 2

1. a

2. 1)

2)
3.
1)
>> x=2:20
x = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
>> a=find(x > 2, 4)
a=2345
>> b=x(a)
b=3456
2)
>> x=2:20
x = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
>> c = find(x >= 10, 4, 'first')
c = 9 10 11 12
>> d = x(c)
d = 10 11 12 13
3)
>> x=2:20
x = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
>> e = find(x~=2, 12, 'last')
e = 8 9 10 11 12 13 14 15 16 17 18 19
>> f = x(e)
f = 9 10 11 12 13 14 15 16 17 18 19 20
4. a)

b)

5.
6.
>> x =-pi:0.1:pi;
>> y = sin(x);
>> z = cos(x);
>> w = tan(x);
>> plot(x, y, ‘bx-‘)
>> hold on
>> plot(x, z, ‘ro-‘)
>> plot(x, w, ‘gx-‘)
>>legend(‘sin(x)’,’cos(x)’,’tan(x)’)
>>xlabel('x')
>> axis([-pi,pi,- 4,4])
>>hold off

7.
>>x1 = -3:0.1:3;
>>y1 = x1.^2;
>>subplot(1,2,1)
>>plot(x1,y1)
>>xlabel(‘x_1’)
>>ylabel(‘y_1’)
>>title(‘y_1 = x_1^2’)
>>x2 = -2:0.1:2;
>>y2 = x2.^3;
>>subplot(1,2,2)
>>plot(x2,y2)
>>xlabel(‘x_2’)
>>ylabel(‘y_2’)
>>title(‘y_2 = x_2^3’)

You might also like