You are on page 1of 2

NANO15

Homework#1

Problem1:
Input:
>>var1=5.34
>>var2=int8(var1)
%%thedoubledatatypecanholdmanyvalues,whileint8holdsintegersfrom127to127
Output:
var1=
5.3400
var2=
5
Problem2:
Input:
%%(a)
>>vec1=6:2:4
>>vec2=4.5:0.25:2.25
>>vec3=(6:0.4:8)
%%(b)
>>vec4=linspace(7,15,3)
>>vec5=linspace(4,19,4)
>>vec6=linspace(10,4,4)
Output:
vec1=
6
4
2
0
2
4
vec2=
4.5000
4.2500
4.0000
3.7500
3.5000
3.2500
3.0000
2.7500
2.5000
2.2500
vec3=
6.0000
6.4000
6.8000
7.2000
7.6000
8.0000
vec4=
7
11
15
vec5=
4
9
14
19
vec6=

10

Problem3:
Input:
%%(a)
>>mat1=rand([3,5])*105
%%(b)
>>mat2=randi([5,20],3,5)
Output:
mat1=

3.6393 0.4986
1.2206
0.9819
3.7668
3.6929
3.5505
1.4905
4.2403
3.1609
0.7970
3.5303
0.1325
2.6008
2.6005
mat2=

11
20
10
6
8

5
12
19
17
11
19
12
10
11
6

Problem4:
Input:
>>x=linspace(pi,pi,15)
>>y=tan(x)
Output:
x=

Columns1through7
3.14162.69282.24401.79521.34640.89760.4488

Columns8through14

0
0.4488 0.8976 1.3464 1.7952 2.2440 2.6928

Column15
3.1416

y=

Columns1through7
0.0000 0.4816 1.2540 4.38134.38131.25400.4816

Columns8through14

0
0.4816 1.2540 4.38134.38131.25400.4816

Column15

0.0000

You might also like