📄 average.m
字号:
% 各变量意义===================================================
% fit1 读取的文件号
% No 观测点数
% j 观测次数编号
% angel 请输入滑坡位移要投影的方向(与x夹角,向y的正方向为正.以dd.mmss的格式)
% month_time 以第一次观测月为1开始的月数(差多少月,值是多少,非观测次数)
% year 记录每次观测的年
% month 记录每次观测的月
% day 记录每次观测的日
% month_interval 每次观测的间隔月数
% x(j,i) 第j次观测的i点的x
% y(j,i) 第j次观测的i点的y
% u(j,i) 第j次观测的i点的x与第1次观测的i点的x之差
% v(j,i0 第j次观测的i点的y与第1次观测的i点的y之差
% total_distchange_angel 每个点的总位移的方位角
% distchange 每个点在所求方向上的总位移
% time 总观测次数
% begin_year_month 要拟合的开始年月
% end_year_month 要拟合的终止年月
% begin_num_want_to_nihe 要拟合的开始年月化成观测编号
% end_num_want_to_nihe 要拟合的终止年月化成观测编号
% switch_bool 开关变量,用来判断要拟合的方法
% nihe_number 要拟合的点号
% x0 拟合和画成图的x坐标
% y0 拟合和画成图的y坐标
% xmax 拟合和画成图的x坐标的最大值
% xmin 拟合和画成图的x坐标的最小值
% ymax 拟合和画成图的y坐标的最大值
% ymin 拟合和画成图的y坐标的最小值
%============================================================
% 各函数的意义======================================================
% alfa 求方位角
% dms_rad 度分秒转为弧度
% get_nihe_num 把起始年月转为观测次数编号
% line_nihe 直线拟合
% linefunction 完成由直线拟合后的画图等工作
% poly_nihe 样条拟合
% polyfunction 完成由样条拟合后的画图等工作
%=============================================================
global fit2
[filename1,pathname1]=uigetfile('*.txt','读入数据');
fit1=fopen(strcat(pathname1,filename1),'rt');
if(fit1==-1)
msgbox('Input File or Path is not correct','Warning','warn');
break;
end
[filename2,pathname2]=uiputfile('*.txt','写入数据');
fit2=fopen(strcat(pathname2,filename2),'wt');
if(fit2==-1)
msgbox('Error by Opening Output File','Warning','warn');
break;
end
%=========================================读数据========================
No=fscanf(fit1,'%d',1); %读取点的个数
j=0; %是日期的编号
month_time(1)=1;
while (1)
temp=fscanf(fit1,'%d',1);
if isempty(temp)
break;
end
j=j+1;
myyear(j)=temp;
mymonth(j)=fscanf(fit1,'%d',1);
myday(j)=fscanf(fit1,'%d',1);
if j~=1
month_interval(j)=mymonth(j)+(myyear(j)-myyear(j-1))*12-mymonth(j-1);
month_time(j)=month_time(j-1)+month_interval(j);
end
for i=1:No
x(j,i)=fscanf(fit1,'%f',1);
y(j,i)=fscanf(fit1,'%f',1);
end
end
time=j;
dx(1)= 835.7262 - x(j,1)
dy(1)= 6403.2090 -y(j,1)
dx(2)= 845.1568 - x(j,2)
dy(2)= 6376.0075 -y(j,2)
dx(3)= 866.1317 - x(j,3)
dy(3)= 6403.4113 -y(j,3)
dx(4)= 863.6753 - x(j,4)
dy(4)= 6397.9629 -y(j,4)
dx(5)= 867.1530 - x(j,5)
dy(5)= 6382.4265 -y(j,5)
dx(6)= 876.6314 - x(j,6)
dy(6)= 6408.2726 -y(j,6)
dx(7)= 883.0696 - x(j,7)
dy(7)= 6394.9029 -y(j,7)
dx(8)= 879.6542 - x(j,8)
dy(8)= 6383.4455 -y(j,8)
fprintf(fit2,'%d\n',No);
for j=1:time
fprintf(fit2,'%d\t%d\t%d\n',myyear(j),mymonth(j),myday(j));
for i=1:No
x(j,i)=x(j,i)+dx(i)/ month_time(time)* month_time(j)
y(j,i)=y(j,i)+dy(i)/ month_time(time)* month_time(j)
fprintf(fit2,'%f\t%f\n',x(j,i),y(j,i))
end
end
fclose('all')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -