标题:[求助]关于3维作图的请教,mesh()或surf()怎么用???
取消只看楼主
livefree
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-6-10
 问题点数:0 回复次数:1 
[求助]关于3维作图的请教,mesh()或surf()怎么用???

初学MATLAB,想用MATLAB作图,可是试了多次没有得到理想的图样,希望有人可以帮帮小弟!!不胜感激

在做电磁正演时获得了地表一些点的坐标和磁异常的水平分量,该如何做图呢?

如得到数据是按照如下格式保存的
X[] m*1 坐标x值
Y[] m*1 坐标y值
Ha[] m*1 磁异常值
都是一维列向量,应该怎么才可以作出 三潍网线图或三维曲面图?我对mesh(x,y,z)和surf(x,y,z)里的各分量的含义不是很清楚,望知道的人不吝赐教!


m文件如下:
function plot_mag
[cfilename cdir]=uigetfile({'*.txt','TXT file(*.txt)';'*.*','All files(*.*)'},...
'Select an TXT file to plot');
cfile=[cdir,cfilename];
clc;
fid=fopen(cfile,'r');
disp(['Reading ',cfile]);
for i=1:10000
if ~feof(fid)
line=fgetl(fid);

if strfind(line,'>LINES')>0
for in=1:length(line)
if line(in:in)=='/'
lines=in;
end
end
end
if strfind(line,'>POINTS')>0
for in=1:length(line)
if line(in:in)=='/'
points=in;
end
end
end

if strfind(line,'>Xpoint')>0
for in=1:length(line)
if line(in:in)=='/'
nend=in;
end
end
npoint=str2num(line(nend+1:length(line)));
Xpoint=fscanf(fid,'%f',[npoint,1]);
disp('...find Xpoint list');

elseif strfind(line,'>Ypoint')>0
Ypoint=fscanf(fid,'%f',[npoint,1]);
disp('...find Ypoint list');

elseif strfind(line,'>HAX')>0
HAX=fscanf(fid,'%f',[npoint,1]);
disp('...find HAX list');

elseif strfind(line,'>ZA')>0
ZA=fscanf(fid,'%f',[npoint,1]);
disp('...find ZA list');

elseif strfind(line,'>DELTAT')>0
DELTAT=fscanf(fid,'%f',[npoint,1]);
disp('...find DeltaT list');
end
end
end
% for i=1:line
% X=Xpoint(i:i*points,:);
% Y=Ypoint(i:i*points,:);
% Z=HAX(i:i*points,:);
% plot3(X,Y,Z)
% hold on
% end;
% figure(1);
% plot3(Xpoint,Ypoint,HAX)


以下是数据的一个简单的例子
>INFO
球心坐标=(0,0,-200)
磁化率=0.0001
>LINES= //10
>POINTS= //10
>Xpoint= //100
0 0 0 0 0 0 0 0 0 0
2 2 2 2 2 2 2 2 2 2
4 4 4 4 4 4 4 4 4 4
6 6 6 6 6 6 6 6 6 6
8 8 8 8 8 8 8 8 8 8
10 10 10 10 10 10 10 10 10 10
12 12 12 12 12 12 12 12 12 12
14 14 14 14 14 14 14 14 14 14
16 16 16 16 16 16 16 16 16 16
18 18 18 18 18 18 18 18 18 18
>Ypoint= // 100
0 10 20 30 40 50 60 70 80 90
2 12 22 32 42 52 62 72 82 92
4 14 24 34 44 54 64 74 84 94
6 16 26 36 46 56 66 76 86 96
8 18 28 38 48 58 68 78 88 98
10 20 30 40 50 60 70 80 90 100
12 22 32 42 52 62 72 82 92 102
14 24 34 44 54 64 74 84 94 104
16 26 36 46 56 66 76 86 96 106
18 28 38 48 58 68 78 88 98 108
>HAX= // 100
-1.86042e-010 -1.85347e-010 -1.83286e-010 -1.79935e-010 -1.75413e-010 -1.69871e-010 -1.63483e-010 -1.56434e-010 -1.4891e-010 -1.41086e-010
-1.8164e-010 -1.80718e-010 -1.78494e-010 -1.75047e-010 -1.70497e-010 -1.64991e-010 -1.587e-010 -1.51799e-010 -1.44463e-010 -1.3686e-010
-1.7707e-010 -1.75946e-010 -1.73584e-010 -1.70068e-010 -1.65515e-010 -1.6007e-010 -1.53896e-010 -1.47159e-010 -1.40028e-010 -1.32656e-010
-1.72347e-010 -1.71045e-010 -1.68571e-010 -1.65011e-010 -1.60481e-010 -1.55119e-010 -1.49082e-010 -1.42528e-010 -1.35612e-010 -1.28483e-010
-1.67484e-010 -1.66029e-010 -1.63471e-010 -1.59893e-010 -1.55409e-010 -1.50152e-010 -1.4427e-010 -1.37913e-010 -1.31226e-010 -1.24347e-010
-1.62496e-010 -1.60916e-010 -1.58298e-010 -1.54727e-010 -1.50313e-010 -1.45181e-010 -1.39472e-010 -1.33325e-010 -1.26877e-010 -1.20256e-010
-1.574e-010 -1.55719e-010 -1.53068e-010 -1.49529e-010 -1.45205e-010 -1.40218e-010 -1.34697e-010 -1.28772e-010 -1.22572e-010 -1.16215e-010
-1.5221e-010 -1.50455e-010 -1.47795e-010 -1.44311e-010 -1.401e-010 -1.35274e-010 -1.29955e-010 -1.24264e-010 -1.18319e-010 -1.1223e-010
-1.46942e-010 -1.45138e-010 -1.42495e-010 -1.39088e-010 -1.35008e-010 -1.3036e-010 -1.25256e-010 -1.19807e-010 -1.14124e-010 -1.08307e-010
-1.41612e-010 -1.39785e-010 -1.37182e-010 -1.33872e-010 -1.29942e-010 -1.25486e-010 -1.20608e-010 -1.1541e-010 -1.09993e-010 -1.04451e-010
>HAY= // 100
1.62766e-011 3.75687e-011 5.77943e-011 7.62527e-011 9.23808e-011 1.05788e-010 1.16268e-010 1.23794e-010 1.28491e-010 1.30603e-010
2.06078e-011 4.18803e-011 6.19318e-011 8.00811e-011 9.57937e-011 1.08713e-010 1.18669e-010 1.25668e-010 1.2986e-010 1.31511e-010
2.49655e-011 4.61751e-011 6.60122e-011 8.38178e-011 9.9088e-011 1.11502e-010 1.20924e-010 1.27392e-010 1.31084e-010 1.32282e-010
2.93364e-011 5.04402e-011 7.00237e-011 8.74526e-011 1.02256e-010 1.14147e-010 1.23028e-010 1.28966e-010 1.32163e-010 1.32919e-010
3.37072e-011 5.46627e-011 7.39548e-011 9.09762e-011 1.05289e-010 1.16645e-010 1.24979e-010 1.30389e-010 1.33099e-010 1.33424e-010
3.80647e-011 5.88303e-011 7.77946e-011 9.43794e-011 1.08183e-010 1.18992e-010 1.26776e-010 1.3166e-010 1.33891e-010 1.33798e-010
4.23957e-011 6.29306e-011 8.15325e-011 9.76543e-011 1.1093e-010 1.21183e-010 1.28416e-010 1.32781e-010 1.34544e-010 1.34045e-010
4.66871e-011 6.69521e-011 8.51589e-011 1.00793e-010 1.13526e-010 1.23217e-010 1.29899e-010 1.33752e-010 1.35058e-010 1.34167e-010
5.09262e-011 7.08835e-011 8.86646e-011 1.0379e-010 1.15967e-010 1.2509e-010 1.31226e-010 1.34574e-010 1.35436e-010 1.34169e-010
5.51008e-011 7.47143e-011 9.20413e-011 1.06638e-010 1.18248e-010 1.26803e-010 1.32396e-010 1.35251e-010 1.35682e-010 1.34054e-010
>ZA= // 100
2.87574e-010 2.83857e-010 2.75322e-010 2.6243e-010 2.4586e-010 2.2644e-010 2.05067e-010 1.82629e-010 1.59942e-010 1.37704e-010
2.89918e-010 2.85191e-010 2.75685e-010 2.61914e-010 2.44597e-010 2.24586e-010 2.02787e-010 1.80084e-010 1.57278e-010 1.35044e-010
2.91853e-010 2.86116e-010 2.75657e-010 2.61036e-010 2.4301e-010 2.22452e-010 2.00274e-010 1.77352e-010 1.54469e-010 1.32276e-010
2.93374e-010 2.86634e-010 2.75241e-010 2.59804e-010 2.4111e-010 2.20052e-010 1.97542e-010 1.74447e-010 1.51527e-010 1.29411e-010
2.94479e-010 2.86746e-010 2.74445e-010 2.58226e-010 2.38909e-010 2.17398e-010 1.94604e-010 1.7138e-010 1.48465e-010 1.2646e-010
2.95165e-010 2.86455e-010 2.73275e-010 2.56315e-010 2.3642e-010 2.14504e-010 1.91475e-010 1.68166e-010 1.45294e-010 1.23433e-010
2.95436e-010 2.85769e-010 2.71741e-010 2.54082e-010 2.33657e-010 2.11386e-010 1.88168e-010 1.64818e-010 1.42027e-010 1.2034e-010
2.95294e-010 2.84693e-010 2.69854e-010 2.5154e-010 2.30634e-010 2.08057e-010 1.84697e-010 1.61348e-010 1.38675e-010 1.17192e-010
2.94743e-010 2.83237e-010 2.67627e-010 2.48704e-010 2.27367e-010 2.04533e-010 1.81078e-010 1.57771e-010 1.35249e-010 1.13999e-010
2.93791e-010 2.81412e-010 2.65072e-010 2.4559e-010 2.23871e-010 2.0083e-010 1.77324e-010 1.54099e-010 1.31762e-010 1.1077e-010
>DELTAT= // 100
1.17809e-010 1.13824e-010 1.06141e-010 9.51976e-011 8.16145e-011 6.61301e-011 4.95259e-011 3.25581e-011 1.59012e-011 1.11498e-013
1.21959e-010 1.17158e-010 1.08674e-010 9.69925e-011 8.27696e-011 6.67672e-011 4.97763e-011 3.25498e-011 1.57497e-011 -8.68099e-014
1.25859e-010 1.20233e-010 1.10953e-010 9.85483e-011 8.37099e-011 6.72195e-011 4.98743e-011 3.24212e-011 1.55073e-011 -3.50483e-013
1.29498e-010 1.23042e-010 1.12973e-010 9.98649e-011 8.4438e-011 6.74913e-011 4.9825e-011 3.21775e-011 1.51791e-011 -6.74948e-013
1.32866e-010 1.25579e-010 1.14734e-010 1.00944e-010 8.49575e-011 6.75876e-011 4.96342e-011 3.18245e-011 1.47704e-011 -1.05558e-012
1.35955e-010 1.27841e-010 1.16234e-010 1.01787e-010 8.52726e-011 6.7514e-011 4.9308e-011 3.13683e-011 1.42866e-011 -1.48773e-012
1.38759e-010 1.29824e-010 1.17474e-010 1.02398e-010 8.53888e-011 6.72769e-011 4.88529e-011 3.08151e-011 1.37334e-011 -1.96677e-012
1.41273e-010 1.31527e-010 1.18457e-010 1.02781e-010 8.5312e-011 6.68829e-011 4.82758e-011 3.01713e-011 1.31163e-011 -2.48808e-012
1.43493e-010 1.32951e-010 1.19185e-010 1.02941e-010 8.50489e-011 6.63395e-011 4.75839e-011 2.94432e-011 1.24408e-011 -3.04715e-012
1.45416e-010 1.34097e-010 1.19662e-010 1.02886e-010 8.46071e-011 6.56541e-011 4.67843e-011 2.86376e-011 1.17126e-011 -3.63951e-012
>END

[此贴子已经被作者于2007-4-9 19:54:49编辑过]

搜索更多相关主题的帖子: mesh surf 
2007-04-09 19:35
livefree
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-6-10
得分:0 
回复:(livefree)[求助]关于3维作图的请教,mesh()或...

对数据的读取如下:
function plot_mag
[cfilename cdir]=uigetfile({'*.txt','TXT file(*.txt)';'*.*','All files(*.*)'},...
'Select an TXT file to plot');
cfile=[cdir,cfilename];
clc;
fid=fopen(cfile,'r');
disp(['Reading ',cfile]);
for i=1:10000
if ~feof(fid)
line=fgetl(fid);

if strfind(line,'>LINES')>0
for in=1:length(line)
if line(in:in)=='/'
lines=in;
end
end
end
if strfind(line,'>POINTS')>0
for in=1:length(line)
if line(in:in)=='/'
points=in;
end
end
end

if strfind(line,'>Xpoint')>0
for in=1:length(line)
if line(in:in)=='/'
nend=in;
end
end
npoint=str2num(line(nend+1:length(line)));
Xpoint=fscanf(fid,'%f',[npoint,1]);
disp('...find Xpoint list');

elseif strfind(line,'>Ypoint')>0
Ypoint=fscanf(fid,'%f',[npoint,1]);
disp('...find Ypoint list');

elseif strfind(line,'>HAX')>0
HAX=fscanf(fid,'%f',[npoint,1]);
disp('...find HAX list');

elseif strfind(line,'>ZA')>0
ZA=fscanf(fid,'%f',[npoint,1]);
disp('...find ZA list');

elseif strfind(line,'>DELTAT')>0
DELTAT=fscanf(fid,'%f',[npoint,1]);
disp('...find DeltaT list');
end
end
end
% for i=1:line
% X=Xpoint(i:i*points,:);
% Y=Ypoint(i:i*points,:);
% Z=HAX(i:i*points,:);
% plot3(X,Y,Z)
% hold on
% end;
% figure(1);
% plot3(Xpoint,Ypoint,HAX)

如何画图便不会了
以下是数据的一个简单的例子,保存为.txt文件:
>INFO
球心坐标=(0,0,-200)
磁化率=0.0001
>LINES= //10
>POINTS= //10
>Xpoint= //100
0 0 0 0 0 0 0 0 0 0
2 2 2 2 2 2 2 2 2 2
4 4 4 4 4 4 4 4 4 4
6 6 6 6 6 6 6 6 6 6
8 8 8 8 8 8 8 8 8 8
10 10 10 10 10 10 10 10 10 10
12 12 12 12 12 12 12 12 12 12
14 14 14 14 14 14 14 14 14 14
16 16 16 16 16 16 16 16 16 16
18 18 18 18 18 18 18 18 18 18
>Ypoint= // 100
0 10 20 30 40 50 60 70 80 90
2 12 22 32 42 52 62 72 82 92
4 14 24 34 44 54 64 74 84 94
6 16 26 36 46 56 66 76 86 96
8 18 28 38 48 58 68 78 88 98
10 20 30 40 50 60 70 80 90 100
12 22 32 42 52 62 72 82 92 102
14 24 34 44 54 64 74 84 94 104
16 26 36 46 56 66 76 86 96 106
18 28 38 48 58 68 78 88 98 108
>HAX= // 100
-1.86042e-010 -1.85347e-010 -1.83286e-010 -1.79935e-010 -1.75413e-010 -1.69871e-010 -1.63483e-010 -1.56434e-010 -1.4891e-010 -1.41086e-010
-1.8164e-010 -1.80718e-010 -1.78494e-010 -1.75047e-010 -1.70497e-010 -1.64991e-010 -1.587e-010 -1.51799e-010 -1.44463e-010 -1.3686e-010
-1.7707e-010 -1.75946e-010 -1.73584e-010 -1.70068e-010 -1.65515e-010 -1.6007e-010 -1.53896e-010 -1.47159e-010 -1.40028e-010 -1.32656e-010
-1.72347e-010 -1.71045e-010 -1.68571e-010 -1.65011e-010 -1.60481e-010 -1.55119e-010 -1.49082e-010 -1.42528e-010 -1.35612e-010 -1.28483e-010
-1.67484e-010 -1.66029e-010 -1.63471e-010 -1.59893e-010 -1.55409e-010 -1.50152e-010 -1.4427e-010 -1.37913e-010 -1.31226e-010 -1.24347e-010
-1.62496e-010 -1.60916e-010 -1.58298e-010 -1.54727e-010 -1.50313e-010 -1.45181e-010 -1.39472e-010 -1.33325e-010 -1.26877e-010 -1.20256e-010
-1.574e-010 -1.55719e-010 -1.53068e-010 -1.49529e-010 -1.45205e-010 -1.40218e-010 -1.34697e-010 -1.28772e-010 -1.22572e-010 -1.16215e-010
-1.5221e-010 -1.50455e-010 -1.47795e-010 -1.44311e-010 -1.401e-010 -1.35274e-010 -1.29955e-010 -1.24264e-010 -1.18319e-010 -1.1223e-010
-1.46942e-010 -1.45138e-010 -1.42495e-010 -1.39088e-010 -1.35008e-010 -1.3036e-010 -1.25256e-010 -1.19807e-010 -1.14124e-010 -1.08307e-010
-1.41612e-010 -1.39785e-010 -1.37182e-010 -1.33872e-010 -1.29942e-010 -1.25486e-010 -1.20608e-010 -1.1541e-010 -1.09993e-010 -1.04451e-010
>HAY= // 100
1.62766e-011 3.75687e-011 5.77943e-011 7.62527e-011 9.23808e-011 1.05788e-010 1.16268e-010 1.23794e-010 1.28491e-010 1.30603e-010
2.06078e-011 4.18803e-011 6.19318e-011 8.00811e-011 9.57937e-011 1.08713e-010 1.18669e-010 1.25668e-010 1.2986e-010 1.31511e-010
2.49655e-011 4.61751e-011 6.60122e-011 8.38178e-011 9.9088e-011 1.11502e-010 1.20924e-010 1.27392e-010 1.31084e-010 1.32282e-010
2.93364e-011 5.04402e-011 7.00237e-011 8.74526e-011 1.02256e-010 1.14147e-010 1.23028e-010 1.28966e-010 1.32163e-010 1.32919e-010
3.37072e-011 5.46627e-011 7.39548e-011 9.09762e-011 1.05289e-010 1.16645e-010 1.24979e-010 1.30389e-010 1.33099e-010 1.33424e-010
3.80647e-011 5.88303e-011 7.77946e-011 9.43794e-011 1.08183e-010 1.18992e-010 1.26776e-010 1.3166e-010 1.33891e-010 1.33798e-010
4.23957e-011 6.29306e-011 8.15325e-011 9.76543e-011 1.1093e-010 1.21183e-010 1.28416e-010 1.32781e-010 1.34544e-010 1.34045e-010
4.66871e-011 6.69521e-011 8.51589e-011 1.00793e-010 1.13526e-010 1.23217e-010 1.29899e-010 1.33752e-010 1.35058e-010 1.34167e-010
5.09262e-011 7.08835e-011 8.86646e-011 1.0379e-010 1.15967e-010 1.2509e-010 1.31226e-010 1.34574e-010 1.35436e-010 1.34169e-010
5.51008e-011 7.47143e-011 9.20413e-011 1.06638e-010 1.18248e-010 1.26803e-010 1.32396e-010 1.35251e-010 1.35682e-010 1.34054e-010
>ZA= // 100
2.87574e-010 2.83857e-010 2.75322e-010 2.6243e-010 2.4586e-010 2.2644e-010 2.05067e-010 1.82629e-010 1.59942e-010 1.37704e-010
2.89918e-010 2.85191e-010 2.75685e-010 2.61914e-010 2.44597e-010 2.24586e-010 2.02787e-010 1.80084e-010 1.57278e-010 1.35044e-010
2.91853e-010 2.86116e-010 2.75657e-010 2.61036e-010 2.4301e-010 2.22452e-010 2.00274e-010 1.77352e-010 1.54469e-010 1.32276e-010
2.93374e-010 2.86634e-010 2.75241e-010 2.59804e-010 2.4111e-010 2.20052e-010 1.97542e-010 1.74447e-010 1.51527e-010 1.29411e-010
2.94479e-010 2.86746e-010 2.74445e-010 2.58226e-010 2.38909e-010 2.17398e-010 1.94604e-010 1.7138e-010 1.48465e-010 1.2646e-010
2.95165e-010 2.86455e-010 2.73275e-010 2.56315e-010 2.3642e-010 2.14504e-010 1.91475e-010 1.68166e-010 1.45294e-010 1.23433e-010
2.95436e-010 2.85769e-010 2.71741e-010 2.54082e-010 2.33657e-010 2.11386e-010 1.88168e-010 1.64818e-010 1.42027e-010 1.2034e-010
2.95294e-010 2.84693e-010 2.69854e-010 2.5154e-010 2.30634e-010 2.08057e-010 1.84697e-010 1.61348e-010 1.38675e-010 1.17192e-010
2.94743e-010 2.83237e-010 2.67627e-010 2.48704e-010 2.27367e-010 2.04533e-010 1.81078e-010 1.57771e-010 1.35249e-010 1.13999e-010
2.93791e-010 2.81412e-010 2.65072e-010 2.4559e-010 2.23871e-010 2.0083e-010 1.77324e-010 1.54099e-010 1.31762e-010 1.1077e-010
>DELTAT= // 100
1.17809e-010 1.13824e-010 1.06141e-010 9.51976e-011 8.16145e-011 6.61301e-011 4.95259e-011 3.25581e-011 1.59012e-011 1.11498e-013
1.21959e-010 1.17158e-010 1.08674e-010 9.69925e-011 8.27696e-011 6.67672e-011 4.97763e-011 3.25498e-011 1.57497e-011 -8.68099e-014
1.25859e-010 1.20233e-010 1.10953e-010 9.85483e-011 8.37099e-011 6.72195e-011 4.98743e-011 3.24212e-011 1.55073e-011 -3.50483e-013
1.29498e-010 1.23042e-010 1.12973e-010 9.98649e-011 8.4438e-011 6.74913e-011 4.9825e-011 3.21775e-011 1.51791e-011 -6.74948e-013
1.32866e-010 1.25579e-010 1.14734e-010 1.00944e-010 8.49575e-011 6.75876e-011 4.96342e-011 3.18245e-011 1.47704e-011 -1.05558e-012
1.35955e-010 1.27841e-010 1.16234e-010 1.01787e-010 8.52726e-011 6.7514e-011 4.9308e-011 3.13683e-011 1.42866e-011 -1.48773e-012
1.38759e-010 1.29824e-010 1.17474e-010 1.02398e-010 8.53888e-011 6.72769e-011 4.88529e-011 3.08151e-011 1.37334e-011 -1.96677e-012
1.41273e-010 1.31527e-010 1.18457e-010 1.02781e-010 8.5312e-011 6.68829e-011 4.82758e-011 3.01713e-011 1.31163e-011 -2.48808e-012
1.43493e-010 1.32951e-010 1.19185e-010 1.02941e-010 8.50489e-011 6.63395e-011 4.75839e-011 2.94432e-011 1.24408e-011 -3.04715e-012
1.45416e-010 1.34097e-010 1.19662e-010 1.02886e-010 8.46071e-011 6.56541e-011 4.67843e-011 2.86376e-011 1.17126e-011 -3.63951e-012
>END

2007-04-09 20:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-130473-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052295 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved