-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm1p2.m
64 lines (39 loc) · 788 Bytes
/
m1p2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%{
Height ℎ (cm) 11 10 9 8 7 6 5 4 3 2 1
Time 𝑡 (s) 7 7.5 8 8.5 9 9.5 11 12 14 19 26
%}
clear all; close all; clc;
h = linspace(11,1,11);
t = [7 7.5 8 8.5 9 9.5 11 12 14 19 26];
f = 250 ./ t;
% the x is h
% the y is f
% linear
%plot(h,f)
% exponential
log_h = log10(h)
log_f = log10(f)
%plot(h, log_f)
% power
%plot(log_h, log_f)
% selcting the power fnx
% f = bh^m <- the function
scatter(log_h, log_f)
p = polyfit(log_h, log_f,1)
new_f_log = polyval(p, log_h);
hold on;
plot(log_h, new_f_log)
% the quality of fit
m = p(1)
b = 10^(p(2))
new_f = b .* (h.^m);
% plotting the fit on it;
hold off;
scatter(h,f); hold on;
plot(h, new_f);
J = sum((new_f - f).^2)
S = sum((new_f - mean(f)).^2)
r_2 = 1 - (J/S)
% if h is 5.4
theF = b * (5.4)^m ;
theT = 250/theF