-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIceChangePlot.m
67 lines (52 loc) · 1.66 KB
/
IceChangePlot.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
64
65
66
67
%% Caclulating the percentage change in ice by counting white pixels Source:
%% https://www.mathworks.com/matlabcentral/answers/12011-count-black-and-white-pixels-on-a-image
%% Counting white pixels in Day 1
%Source: https://www.mathworks.com/matlabcentral/answers/12011-count-black-and-white-pixels-on-a-image
image_1=imread('1359filter.png');
whitepix_1=0;
blackpix_1=0;
for R=1:720
for C=1:1280
if image_1(R,C)==1;
whitepix_1=whitepix_1+1;
else
blackpix_1=blackpix_1+1
end
end
end
area_1=whitepix_1;
for number = 1359:1699; % the images we are working with
filtered_name=strcat(num2str(number),'filter', '.png');
image_x=imread(filtered_name);
whitepix=0;
blackpix=0;
day=number-1359+1;
index=0;
for R=1:720
for C=1:1280
if image_x(R,C)==1;
whitepix=whitepix+1;
else
blackpix=blackpix+1;
end
end
end
area=whitepix
ice_change_tag= ((area-area_1)/area_1)*100;
%% Source:https://www.mathworks.com/matlabcentral/answers/113171-how-to-store-values-from-a-loop
y_val(day)=ice_change_tag;
end
x=linspace(1,183,341);
figure
title('Change in ice area');
plot(x,y_val);
%% Using polyfit to model ice change as polynomial regression
poly=polyfit(x,y_val,3); % n=3
val=polyval(poly,x);
% Source: https://www.mathworks.com/matlabcentral/newsreader/view_thread/2131
figure
xlabel('Days');
ylabel('Percentage change in ice-area');
title('Model as polynomial regression');
plot(x,val, 'Color', 'red');
exp=-3.29472397891272e-06;