-
Notifications
You must be signed in to change notification settings - Fork 0
/
deagregation_plot.m
184 lines (171 loc) · 4.31 KB
/
deagregation_plot.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
%%%%descargar los archivos de webiio del openquake en formato csv, ademas
%%%%de un archivo mean que es el resultado de el promedio ponderado de cada
%%%%realizacion con los pesos de las realizaciones, esto esta
%%%%comprovado.
feature('DefaultCharacterSet', 'UTF8');
[file,path] = uigetfile('*.csv','MultiSelect', 'on');
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
end
img=fullfile(path,file);
if iscell(img)==1;
for i=1:length(img);
fileID = fopen(img{1,i});
C = textscan(fileID,'%s %s %s %s','Delimiter',',');
fclose(fileID);
MMM=[];
MMM1=[];
MMM2=[];
MMM3=[];
MMM4=[];
j=0;
k=0;
l=0;
p=0;
for i=1:length(C{1})
if str2num(C{1}{i})<99999999999999;
j=j+1;
k=k+1;
l=l+1;
p=p+1;
if str2num(C{1}{i})*0==0; MMM1(j)=str2num(C{1}{i});else MMM1(j)=0;end;
if str2num(C{2}{i})*0==0; MMM2(k)=str2num(C{2}{i});else MMM2(k)=0;end;
if str2num(C{3}{i})*0==0; MMM3(l)=str2num(C{3}{i});else MMM3(l)=0;end;
if str2num(C{4}{i})*0==0; MMM4(p)=str2num(C{4}{i});else MMM4(p)=0;end;
MMM=transpose([MMM1;MMM2;MMM3;MMM4]);
else;
end;
end;
ejex=C{1}{3}
ejey=C{2}{3}
ejez='Poe'
i=0;
j=0;
k=0;
x1 = MMM(:,1); xx1=unique(x1);xxx1=length(unique(x1));
x2 = MMM(:,2); xx2=unique(x2);xxx2=length(unique(x2));
x3 = MMM(:,3); xx3=unique(x3);xxx3=length(unique(x3));
x4 = MMM(:,4); xx4=unique(x4);xxx4=length(unique(x4));
M=[];
MM=[];
for i=1:xxx1;
for j=1:xxx2;
k=k+1;
M(j)=x3(k);
end;
MM=[MM;M];
end;
MM=transpose(MM)
i=length(MM)
% i=20
figure
MM=MM(1:i,:)
h=bar3(MM,0.5)
title('Desagregação Magnitude-Distância')
ax = gca;
ax.XTick = [1:1:length(xx1)];
ax.XTickLabels = transpose(xx1)-(xx1(2)-xx1(1))*0.5;
ax.YTick = [1:1:length(MM)];
ax.YTickLabels = transpose(xx2)-(xx2(2)-xx2(1))*0.5;
% hh = get(h(1),'parent');
% hhh = get(h(2),'parent');
% set(hh,'xticklabel',transpose(xx1)-(xx1(2)-xx1(1))*0.5);
% % hh = get(h(3),'parent');
% xtick = [1:1:length(MM)];
% set(hhh,'yticklabel',transpose(xx2));
xlabel(ejex)
ylabel(ejey)
zlabel(ejez)
axis tight
end;
else
feature('DefaultCharacterSet', 'Windows-1250');
%%%si solo se escoge uno
fileID = fopen(img);
C = textscan(fileID,'%s %s %s %s','Delimiter',',');
fclose(fileID);
MMM=[];
MMM1=[];
MMM2=[];
MMM3=[];
MMM4=[];
j=0;
k=0;
l=0;
p=0;
for i=1:length(C{1})
if str2num(C{1}{i})<99999999999999;
j=j+1;
k=k+1;
l=l+1;
p=p+1;
if str2num(C{1}{i})*0==0; MMM1(j)=str2num(C{1}{i});else MMM1(j)=0;end;
if str2num(C{2}{i})*0==0; MMM2(k)=str2num(C{2}{i});else MMM2(k)=0;end;
if str2num(C{3}{i})*0==0; MMM3(l)=str2num(C{3}{i});else MMM3(l)=0;end;
if str2num(C{4}{i})*0==0; MMM4(p)=str2num(C{4}{i});else MMM4(p)=0;end;
MMM=transpose([MMM1;MMM2;MMM3;MMM4]);
else;
end;
end;
ejex=C{1}{3};
ejey=C{2}{3};
ejez='% contribuição de ameaça';
i=0;
j=0;
k=0;
x1 = MMM(:,1); xx1=unique(x1);xxx1=length(unique(x1));
x2 = MMM(:,2); xx2=unique(x2);xxx2=length(unique(x2));
x3 = MMM(:,3); xx3=unique(x3);xxx3=length(unique(x3));
%%hacer q te pida el tiempo de exposion
rx3=(-1/50)*log(1-x3);
nx3=rx3/(-1/50)*log(1-prod(1-x3));
x4 = MMM(:,4); xx4=unique(x4);xxx4=length(unique(x4));
M=[];
MM=[];
for i=1:xxx1;
for j=1:xxx2;
k=k+1;
M(j)=nx3(k);
end;
MM=[MM;M];
end;
MM=100*transpose(MM);
%%%% descoemtar cuanco el ejej de distacia sea muy grande y no se observe
%%%% nada en rango de gra distacia
i=20;
MM=MM(1:i,:);
figure;
h=bar3(MM,0.9);
title('Desagregação Magnitude-Distância jb');
ax = gca;
ax.XTick = [1:1:length(xx1)];
G=transpose(xx1)-(xx1(2)-xx1(1))*0.5;
UX=2;
for i=1:length(G);
if floor((i)/UX)<(i)/UX;GX{i}='';else GX{i}=sprintf('%.1f',G(i)); end;
end;
ax.XTickLabels = GX;
ax.YTick = [1:1:length(MM)];
G=transpose(xx2)-(xx2(2)-xx2(1))*0.5;
UX=2;
for i=1:length(G);
if floor((i)/UX)<(i)/UX;GY{i}='';else GY{i}=sprintf('%.0f',G(i)); end;
end;
ax.YTickLabels = GY;
xlabel(ejex);
ylabel(ejey);
zlabel(ejez);
axis tight;
for k = 1:length(h)
zdata = h(k).ZData;
h(k).CData = zdata;
h(k).FaceColor = 'interp';
end
colormap jet;
colorbar;
view(-60,25);
nfig=sprintf('%s.svg',file(1:end-4));
saveas(gcf,nfig);
end;