how to display three one dimensional vectors as a 2 dimensional image

2 ビュー (過去 30 日間)
Chris McGuinness
Chris McGuinness 2016 年 7 月 12 日
回答済み: Robert 2016 年 7 月 12 日
Hi, This should be simple. I think there must be a very easy way to do this but I cannot figure it out.
I have data for the angle of a beam in theta and phi and the intensity of that beam. I want to plot it on a polar plot, so I can see the intensity of beams coming from different directions. I can use polar to plot this once I have a 2D array of intensities. But before that I must convert the data for beam intensities from a random array of [theta,phi,I] where theat, and phi, and I are all one dimensional vectors, onto some regular spaced grid. When I try meshgrid I get the error that theta or phi are not monotonically increasing. What can I do?
Thanks!

回答 (1 件)

Robert
Robert 2016 年 7 月 12 日
To create a mesh from your data, you could use delaunay and trisurf, which don't need the x and y values to be evenly spaced. Below is an example that should help get you started. In the conversion to Cartesian, you can scale by I to map intensity to position, or leave it out and visualize intensity with color only.
I hope I interpreted your question correctly. At the very least this script makes cool looking plots!
n = 1000; % number of samples
% Example data
theta = rand(n,1)*360;
phi = rand(n,1)*180 - 90;
I = rand(n,1)+4+2*sind(theta).^2;
% Convert to Cartesian
X = cosd(theta).*sind(phi);
Y = sind(theta).*sind(phi);
Z = cosd(phi);
% X = I.*cosd(theta).*sind(phi);
% Y = I.*sind(theta).*sind(phi);
% Z = I.*cosd(phi);
% Create and show a triangle mesh from points
tri = delaunay(X,Y);
trisurf(tri,X,Y,Z,I);
axis equal
rotate3d on
view(2) % show the 2D (XY) view

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by