1 | function t1 = conversion(type, t1,repnum) |
---|
2 | |
---|
3 | m = size(repnum); |
---|
4 | byte = 'Bytes'; |
---|
5 | kbyte = 'KBytes'; |
---|
6 | mbyte = 'MBytes'; |
---|
7 | gbyte = 'GBytes'; |
---|
8 | bit = 'bits'; |
---|
9 | kbit = 'Kbits'; |
---|
10 | mbit = 'Mbits'; |
---|
11 | gbit = 'Gbits'; |
---|
12 | |
---|
13 | if(strcmp(kbyte,repnum) == 1) |
---|
14 | if(strcmp(type,'Bytes')) |
---|
15 | t1 = t1*1024; |
---|
16 | |
---|
17 | elseif(strcmp(type,'MBytes')) |
---|
18 | t1 = t1/1024; |
---|
19 | |
---|
20 | elseif(strcmp(type,'GBytes')) |
---|
21 | t1 = t1/(1024*1024); |
---|
22 | end |
---|
23 | |
---|
24 | elseif(strcmp(mbyte,repnum) == 1) |
---|
25 | if(strcmp(type,'Bytes')) |
---|
26 | t1 = t1*1024*1024; |
---|
27 | |
---|
28 | elseif(strcmp(type,'GBytes')) |
---|
29 | t1 = t1/1024; |
---|
30 | |
---|
31 | elseif(strcmp(type, 'KBytes')) |
---|
32 | t1 = t1*1024; |
---|
33 | end |
---|
34 | |
---|
35 | elseif(strcmp(gbyte,repnum)) |
---|
36 | if(strcmp(type,'Bytes')) |
---|
37 | t1 = t1*1024*1024*1024*1024; |
---|
38 | |
---|
39 | elseif(strcmp(type,'MBytes')) |
---|
40 | t1 = t1*1024*1024*1024; |
---|
41 | |
---|
42 | elseif(strcmp(type, 'KBytes')) |
---|
43 | t1 = t1*1024*1024; |
---|
44 | end |
---|
45 | |
---|
46 | elseif(strcmp(byte,repnum)) |
---|
47 | if(strcmp(type,'KBytes')) |
---|
48 | t1 = t1/1024; |
---|
49 | |
---|
50 | elseif(strcmp(type,'MBytes')) |
---|
51 | t1 = t1/(1024^2); |
---|
52 | |
---|
53 | elseif(strcmp(type, 'GBtes')) |
---|
54 | t1 = t1/(1024*1024*1024); |
---|
55 | end |
---|
56 | |
---|
57 | %%% from here bits to KMGbits |
---|
58 | elseif(strcmp(bit,repnum)) |
---|
59 | if(strcmp(type ,'Kbits')) |
---|
60 | t1 = t1/1024; |
---|
61 | elseif(strcmp(type, 'Mbits')) |
---|
62 | t1 = t1/(1024*1024); |
---|
63 | elseif(strcmp(type, 'Gits')) |
---|
64 | t1 = t1/(1024*1024*1024); |
---|
65 | end |
---|
66 | elseif(strcmp(kbit,repnum)) |
---|
67 | if(strcmp(type, 'bits')) |
---|
68 | t1 = t1 * 1024; |
---|
69 | elseif(strcmp(type, 'Mbits')) |
---|
70 | t1 = t1/1024; |
---|
71 | elseif(strcmp(type, 'Gbits')) |
---|
72 | t1= t1/(1024*1024); |
---|
73 | end |
---|
74 | elseif(strcmp(mbit,repnum)) |
---|
75 | if(strcmp(type,'bits')) |
---|
76 | t1 = t1*1024*1024; |
---|
77 | elseif(strcmp(type,'Kbits')) |
---|
78 | t1 = t1*1024; |
---|
79 | elseif(strcmp(type,'Gbits')) |
---|
80 | t1 = t1/1024; |
---|
81 | end |
---|
82 | elseif(strcmp(gbit,repnum)) |
---|
83 | if(strcmp(type,'bits')) |
---|
84 | t1 = t1*1024*1024*1024; |
---|
85 | elseif(strcmp(type, 'Kbits')) |
---|
86 | t1 = t1*1024*1024; |
---|
87 | elseif(strcmp(type, 'Mbits')) |
---|
88 | t1 = t1*1024; |
---|
89 | end |
---|
90 | end |
---|
91 | return |
---|