File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ % problems 6.3,6.7,6.13
2
+ ans2life= 42 ; % I get an error if I start with a function
3
+
4
+ % Problem 6.3
5
+ function FV = future_value(Vo , I , n )
6
+ FV = Vo *(1 + I ).^n ;
7
+ endfunction
8
+ value = future_value(1000 ,0.05 ,120 )
9
+
10
+ % problem 6.7
11
+ function height = height(time )
12
+ if (time <= 0 )
13
+ fprintf(" Error: time must be greater than zero" )
14
+ return
15
+ else
16
+ height = - 9.8 / 2 * time .^ 2 + 125 * time + 500 ;
17
+ endif
18
+ endfunction
19
+
20
+ time = [0 : 0.5 : 30 ];
21
+ height = height(time );
22
+ plot(time ,height )
23
+ [maximum_height , maximum_time ] = max(height );
24
+ maximum_time = maximum_time / 2 % because interval of 0.5
25
+
26
+ % Problem 6.13
27
+ myfunction = @(x ) - x .^ 2 - 5 * x - 3 + exp(x );
28
+ x = [-5 , 5 ];
29
+ fplot(myfunction , x );
30
+ minvalue = fminbnd(myfunction , - 5 ,5 )
31
+
32
+
33
+
34
+
You can’t perform that action at this time.
0 commit comments