Professional Documents
Culture Documents
Matlab Tutorial
Matlab Tutorial
>> x=-4.0:0.25:6.0;
>> p=[2, 3, 4, -5, -6, 3]; % 2x^5 + 3x^4 + 4x^3 -5x^2 -6x +3
>> v=polyval(p,x);
>> roots(p)
ans =
-0.8954 + 1.6642i
-0.8954 - 1.6642i
-1.0654
0.9342
0.4220
plot(x,v,'LineWidth',3,'color','r')
>>
4
2.5
x 10
1.5
0.5
-0.5
-4
-3
-2
-1
q=
1.0e+003 *
0.3369 0.4999 -1.6000
>> n=1;
>> q=polyfit(x,v,n)
q=
1.0e+003 *
1.1738 1.0111
>> R=corrcoef(x,v);
>> R(1,2)
ans =
0.7214
>>
>> clear
>> sales = round(100*rand(30,4))
sales =
81
91
13
91
63
10
28
71
3
28
5
10
82
69
75
26
51
70
89
96
55
8
5
53
78
93
13
57
55
96
96
16
97
96
49
80
14
42
92
79
96
66
4
85
93
68
76
74
39
66
17
32
95
3
44
38
77
80
19
49
45
65
71
75
28
68
66
16
12
50
96
34
59
22
14
15
26
84
25
81
24
93
35
20
25
62
47
35
83
59
55
92
29
76
75
38
57
47
1
34
16
79
31
53
17
60
26
65
69
75
45
8
23
91
15
83
54
100
8
44
>> sorted_sales=sort(sales)
sorted_sales =
4
10
13
14
16
17
28
3
3
5
10
12
16
19
14
15
20
24
25
25
26
1
5
8
8
8
13
15
39
42
49
55
63
66
66
68
74
76
79
80
81
85
91
91
92
93
96
96
96
96
97
22
28
28
32
34
38
44
45
49
50
59
65
66
68
69
71
71
75
77
80
82
95
96
26
29
35
35
38
47
51
55
55
57
59
62
70
75
75
76
81
83
84
89
92
93
96
16
17
23
26
31
34
44
45
47
53
53
54
57
60
65
69
75
78
79
83
91
93
100
>> days=1:30;
>> subplot(2,2,1);
>> plot(days, sales(:,1))
>> subplot(2,2,2);
>> plot(days, sales(:,2))
>> subplot(2,2,3);
>> plot(days, sales(:,3))
>> subplot(2,2,4);
>> plot(days, sales(:,4))
>>
100
100
80
80
60
60
40
40
20
20
10
20
30
100
100
80
80
60
60
40
40
20
20
10
20
30
10
20
30
10
20
30
Also,
>> R=corrcoef(sales)
R=
1.0000
-0.0636
-0.2455
0.1253
-0.0636
1.0000
-0.0070
-0.1968
-0.2455
-0.0070
1.0000
-0.0851
0.1253
-0.1968
-0.0851
1.0000
>> R=corrcoef(sorted_sales)
R=
1.0000 0.9634 0.9512 0.9464
741.5610
>> sqrt(variance)
ans =
27.2316
>>
>> clear
>> clear
>> x=linspace(-1.0,0.2,50);
>> y=humps(x);
>> plot(x,y)
>> x=linspace(-1.0,2.5,50);
>> y=humps(x);
>> plot(x,y)
100
80
60
40
20
-20
-1
-0.5
0.5
1.5
2.5
23.7579
>>