|
楼主 |
发表于 2007-1-24 15:40
|
显示全部楼层
回复 #7 xjzuo 的帖子
我的代码如下:
%一、将所用坐标值读入矩阵
number=437437;%经纬度的个数,也就是所用文本文件的行数
jingdu=zeros(1,number);weidu=zeros(1,number);
pf=zeros(1,number);ps=zeros(1,number);t1=zeros(1,number);
guodu=zeros(3,1);
fid=fopen('d:\pf.txt','r');
for n=1:number
guodu=fscanf(fid,'%f %f %f\n',3);jingdu(n)=guodu(1);
weidu(n)=guodu(2);pf(n)=guodu(3);
end
fclose(fid);
fid=fopen('d:\t1.txt','r');
for n=1:number
guodu=fscanf(fid,'%f %f %f\n',3);t1(n)=guodu(3);
end
fclose(fid);
%二、计算AB直线与曲线的交点,并写入AB文本
syms x
fid=fopen('d:\AB.txt','w');
for n=1:number
x1=273.15;y1=pf(n);x2=t1(n);y2=0.375;
a=(y2-y1)/(x2-x1);b=y1-a*x1;
Y=1000*(a*x+b)-exp(14.717-1886.79/x);
q=solve(Y);t=double(q);p=a*t+b;
if imag(t)~=0
t=0;
end
if imag(p)~=0
p=0;
end
fprintf(fid,'%f %f %f\n',jingdu(n),weidu(n),t);
fprintf(fid,'%f %f %f\n',jingdu(n),weidu(n),p);
end
fclose(fid);
pf文本很大,共有437437行,部分如下:
97.2866 39.7036 3.16
97.295 39.7036 2.74
97.3033 39.7036 2.66
97.32 39.6953 2.74
97.37 39.6786 2.44
97.37 39.6703 2.56
97.3783 39.6703 2.42
97.42 39.6703 2.49
97.4283 39.6703 2.96
97.4366 39.6703 2.63
97.395 39.662 2.50
97.4033 39.662 2.43
97.4116 39.662 2.64
96.845 39.6453 2.52
96.8533 39.6453 2.64
97.57 39.637 2.68
97.5283 39.6286 2.46
97.5616 39.6286 2.44
97.57 39.6286 2.71
97.5783 39.6286 2.69
97.5866 39.6286 2.74
97.52 39.6203 2.76
97.5283 39.6203 2.94
97.5366 39.6203 2.45
96.3033 39.612 2.64
96.345 39.6036 2.67
96.3533 39.6036 2.52
96.3367 39.5953 2.50
96.345 39.5953 2.44
96.3533 39.5953 2.76
95.2451 39.587 2.48
95.2534 39.587 2.60
95.3367 39.587 2.58
95.345 39.587 2.57
95.4284 39.587 2.47
96.22 39.587 2.52
96.2283 39.587 2.86
96.2367 39.587 3.31
96.245 39.587 3.39
96.2533 39.587 2.43
96.27 39.587 2.53
96.2783 39.587 2.61
96.2867 39.587 2.90
96.3033 39.587 2.60
96.3117 39.587 2.99
96.32 39.587 3.10
96.3283 39.587 3.33
96.3367 39.587 3.45
96.345 39.587 2.98
96.3533 39.587 3.27
96.3617 39.587 2.52
96.4033 39.587 2.39
95.2451 39.5786 2.80
95.2534 39.5786 3.11
95.2617 39.5786 2.69
t1文本也很大,共有437437行,部分如下:
97.2866 39.7036 268.44
97.295 39.7036 269.15
97.3033 39.7036 269.27
97.32 39.6953 269.14
97.37 39.6786 269.65
97.37 39.6703 269.45
97.3783 39.6703 269.68
97.42 39.6703 269.57
97.4283 39.6703 268.77
97.4366 39.6703 269.32
97.395 39.662 269.55
97.4033 39.662 269.66
97.4116 39.662 269.32
96.845 39.6453 269.52
96.8533 39.6453 269.30
97.57 39.637 269.24
97.5283 39.6286 269.62
97.5616 39.6286 269.64
97.57 39.6286 269.20
97.5783 39.6286 269.23
97.5866 39.6286 269.15
97.52 39.6203 269.12
97.5283 39.6203 268.82
97.5366 39.6203 269.64
96.3033 39.612 269.30
96.345 39.6036 269.27
96.3533 39.6036 269.52
96.3367 39.5953 269.54
96.345 39.5953 269.64
96.3533 39.5953 269.10
95.2451 39.587 269.58
95.2534 39.587 269.39
95.3367 39.587 269.41
95.345 39.587 269.44
95.4284 39.587 269.59
96.22 39.587 269.52
96.2283 39.587 268.93
96.2367 39.587 268.19
96.245 39.587 268.05
96.2533 39.587 269.66
96.27 39.587 269.49
96.2783 39.587 269.37
96.2867 39.587 268.87
96.3033 39.587 269.37
96.3117 39.587 268.72
96.32 39.587 268.53
96.3283 39.587 268.15
96.3367 39.587 267.95
96.345 39.587 268.74
96.3533 39.587 268.26
96.3617 39.587 269.51
96.4033 39.587 269.73
95.2451 39.5786 269.05
95.2534 39.5786 268.52
95.2617 39.5786 269.23
95.27 39.5786 269.53
95.2784 39.5786 269.42
95.2867 39.5786 269.57
95.345 39.5786 269.18
95.3534 39.5786 269.28
95.3617 39.5786 269.10
95.3784 39.5786 269.39
95.6534 39.5786 269.42
95.6617 39.5786 269.22
现在的问题是:计算到1000多行时就报错,而且是随即的,我试算多次,有时算到1200多行,有时算到1400多行,总之就是不确定.不知道问题出在哪里.
报错如下:
??? Error using ==> reshape
To RESHAPE the number of elements must not change.
Error in ==> sym.minus at 29
X = reshape(X,size(A));
Error in ==> shuzhijisuan2 at 27
p1=1000*(a*x+b)-exp(14.717-1886.79/x);
这个就是整个问题,感谢斑竹的提醒,在此道歉先
[ 本帖最后由 renminyingxong 于 2007-1-24 15:48 编辑 ] |
|