-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreaddataWOReClass2.m
42 lines (38 loc) · 1.02 KB
/
readdataWOReClass2.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
%'C:\Users\Administrator\Desktop\newfile2\extract1re.txt'
%dlmread('C:\Users\Administrator\Desktop\newfile2\extract2re.txt','\t',6,0);
function datam = readdataWOReClass2(path)
fid1 = fopen(path);
i=1;
[names,values] = textread(path,'%s%f',5);
ncols=values(1);
nrows=values(2);
ex = textread(path,'%n','headerlines',6);
ex2 = reshape(ex,ncols,nrows);
datam = ex2';
n2 = length(unique(datam));
uni2 = unique(datam);
for i = 1:n2
if(uni2(i)==1)
%farmland
datam((datam==uni2(i)))=14;
elseif(uni2(i)==2)
%forest
datam((datam==uni2(i)))=5.5;
elseif(uni2(i)==3)
%River
datam((datam==uni2(i)))=26;
elseif(uni2(i)==4)
%Grass Land
datam((datam==uni2(i)))=33;
elseif(uni2(i)==5)
%Urban land
datam((datam==uni2(i)))=42;
elseif(uni2(i)==6)
%Indus land
datam((datam==uni2(i)))=58;
elseif(uni2(i)<0)
%background color
datam((datam==uni2(i)))=0;
end
end
end