Skip to content

Commit f0e1181

Browse files
authored
Added hw
1 parent 93359cd commit f0e1181

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Matlab HW5/HW5.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+

Matlab HW5/Output and graphs.pdf

19.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)