作者vacuousrock (只是过客)
看板MATLAB
标题[问题] 使用Matlab读txt档画3D图
时间Wed Jan 22 00:05:12 2014
小弟因为研究的需求,需将量测的天线场型data用Matlab画出
data为三个一维矩阵,如下所示
Theta Phi Directivity
0 0 -1.275
5 0 0.3321
10 0 1.572
:
180 0 -0.9896
0 5 -1.275
5 5 2.509
:
180 5 -0.9896
:
180 355 -0.9896
完整data连结:
http://ppt.cc/305a
照道理说画出来的图形应该会长这样:
http://ppt.cc/YHSp
只不过,小弟参照一些网路上的程式码,画了许久
图形却始终长得不太一样:
http://ppt.cc/rdAc
不晓得是哪些步骤或逻辑有错
底下附上小弟的程式码,麻烦版上的大大帮忙指点迷津
谢谢
----
clear all
close all
clc
A = load('farfield.txt');
theta = A(:,1);
phi = A(:,2);
r = A(:,3);
theta = theta*pi/180;
phi = phi*pi/180;
theta = meshgrid(theta); %这三行meshgrid,总觉得哪里怪怪的,不太明白和
phi = meshgrid(phi); %[theta, phi] = meshgrid(theta, phi)的差别
r = meshgrid(r); %而r = meshgrid(r)把同一column上每点值大小变一样
%似乎不太对
[x, y, z] = sph2cart(phi, theta, r);
mesh(x,y,z)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.129.19.17
※ 编辑: vacuousrock 来自: 220.129.19.17 (01/22 00:08)
1F:推 profyang:你读进来的资料是一堆相同的theta有不同的phi在变化 01/22 02:31
2F:→ profyang:而要用meshgrid(theta,phi)用意是让两个不同长度的向量 01/22 02:32
3F:→ profyang:出来size一样 01/22 02:32
4F:→ profyang:简单来说 人家要用meshgrid的话是本来他的theta和phi分别 01/22 02:34
5F:→ profyang:是像类似这样: theta=0:1:180; phi=0:1:360 总之本来两个 01/22 02:35
6F:→ profyang:size不同 但是meshgrid之後size会一样 01/22 02:36
7F:→ profyang:theta=0:5:180; phi=0:5:355这样 而r应该要是37*72的矩阵 01/22 02:37
8F:→ profyang:另外我是没有mesh画过 一般天线这种图都是用surf画吧? 01/22 02:38
9F:推 profyang:还有,你的directivity是单位已经是dBi了吗? 01/22 02:52
10F:推 profyang:一般都不会用dBi画场型图吧~要取回去 01/22 02:57