How do I plot wireless signal strength measurements using a spherical plot

4 visualizzazioni (ultimi 30 giorni)
Hi,
I am completely new to using Matlab and have only started to look at it as I want a way to present wireless measurements taking from a wireless router. The router was kept at a set distance from the computer and was rotated by 360 degrees through the X and Y axis. Measurements where taken at 10 degree increments through each plane. I am having great trouble to understand the concept of how to plot these coordinates using Matlab.
Can anybody please help and point me in the right direction?
Thanks Mark
  2 Commenti
arich82
arich82 il 28 Lug 2015
Just to clarify--
Your data is sampled at every 10 degrees (so 36 samples around the circumference): does this mean you have 72 data points (36 around the X-plane equator, and 36 around the Y-plane prime meridian), or do you have 1296 samples (36 rings of 36 data points each)?
Note: sph2cart might prove helpful; scatter3 or surf might be useful if you want 3-D visualization.
mdowney
mdowney il 28 Lug 2015
Modificato: mdowney il 28 Lug 2015
Hi,
I have 36 rings of 36 data points - a total of 1296 samples
I hope I am explaining it correctly.
I would like to generate something similar to this...
Many Thanks

Accedi per commentare.

Risposte (3)

arich82
arich82 il 29 Lug 2015
Modificato: arich82 il 29 Lug 2015
[Edited for grammar.]
Sorry for the delayed reply: I typed this up yesterday afternoon, but got called away before I could post it.
I'm afraid I might have misled you with my question. With 10 degree spacing, you should have 18 rings with 36 samples each; otherwise, half your data points would be duplicates (possible, but unlikely).
You can make a wire plot as you described using plot3, though it takes a little finessing since Matlab uses phi as elevation from the x-axis instead of z-, and ultimately, might not be very useful.
I'll construct some dummy data and show three plot types you might wish to consider.
dtr = pi/180;
th = [0:10:180].'*dtr;
phi = [0:10:360].'*dtr + 90*dtr; % add 90 degrees so lines start at top of sphere
r = 1;
[TH, PHI, R] = meshgrid(th, phi, r);
% function for dummy data
f = @(th, phi, r) r.*sin(2*th).*cos(4*phi);
data = f(TH, PHI, R);
meshgrid takes the vectors specified by theta, phi, and r and creates 3-D arrays, suitable for plotting; however, since r only has a single value equal to one, the arrays are equivalent to matrices, i.e. m-by-n-by-1. Also, since Matlab's version of spherical coordinates uses phi to denote elevation from the x-axis, not the z-axis, we've added 90-degrees to phi to better replicate your example plot.
(Note that I'm assuming you already have data, so you won't need to define the anonymous function f, and that your data is in the form of a 36-by-18 matrix; my examples are size 37-by-19, because I've duplicated the point at the pole [this is to prevent holes in the surface plot]; you might need to pad your data using something like data = [data(end, :); data]; data = [data(:, end), data];, which prepends the original matrix with its own last column and row.)
Note that the data is in spherical coordinates, but Matlab can really only plot cartesian in 3-D. To generate the plot data, we can use sph2cart:
[X, Y, Z] = sph2cart(TH, PHI, R);
The first method we'll look at uses plot3 and recreates the wireframe you showed. Unfortunately, the entire line object must be a solid color (unless the newer version of Matlab has added a new feature), so it won't be terribly useful for displaying the intensity.
figure;
axes;
plot3(X(:), Y(:), Z(:));
You can add some formatting to make it look more like your example (search the help docs to understand what these commands are doing):
grid('on')
set(gca, 'Ztick', [])
set(gca, 'XMinorGrid', 'on')
set(gca, 'YMinorGrid', 'on')
axis('equal');
axis('square');
xlabel('x')
ylabel('y')
zlabel('z')
title('plot3')
The above reasonably reproduces your example, but isn't terribly useful since it doesn't make use of the data.
To plot just the data points you actually measured, try scatter3:
figure;
axes;
scatter3(X(:), Y(:), Z(:), 15, data(:), 'filled'); % colon converts matrix to vector
% formatting boiler plate
grid('on')
set(gca, 'Ztick', [])
set(gca, 'XMinorGrid', 'on')
set(gca, 'YMinorGrid', 'on')
axis('equal');
axis('square');
xlabel('x')
ylabel('y')
zlabel('z')
title('scatter3')
Finally, consider using a surface plot:
figure;
axes;
surf(X, Y, Z, data);
% formatting boiler plate
grid('on')
set(gca, 'Ztick', [])
set(gca, 'XMinorGrid', 'on')
set(gca, 'YMinorGrid', 'on')
axis('equal');
axis('square');
xlabel('x')
ylabel('y')
zlabel('z')
title('surf')
If you want, you can use shading to interpolate the data, instead of the having a patch-work quilt, but interpolation may introduce artifacts into the representation of your data:
shading('interp')
There's a lot of options above. Search the help docs for anything you don't understand, and feel free to ask another question if you're struggling with anything. (And please accept this answer if it helps.)
  4 Commenti
mdowney
mdowney il 29 Lug 2015
Many thanks for your help - it really is appreciated :-)
I am having trouble in how to input my data - my data is currently in dB's and I am unsure on how to enter this data into the samples you have provided. Does this information need to be adjusted?
Could you please possibly provide me with direction?
arich82
arich82 il 30 Lug 2015
For the surface plot, the units on data don't really matter (though they will affect how well the colorbar is used); data is just used to index the color of the surface plot, and doesn't affect the spatial dimensions. Do you want some other unit than dB?
Assuming your data is in a matrix, just rename that matrix data and delete the two lines above where I constructed the dummy data, and the above code should get you a preliminary plot. (Note that you might need to resize th and phi depending on the actual number of data points you have.)
If it's not in a matrix, then you'll have to describe what you have/want a little more precisely.
(Note: It is possible to attach data files to these posts. Assuming you have the data loaded in Matlab, you can save the workspace data to a .mat file and post it; if we knew the exact format of your data, it might make it easier to understand your difficulty in adapting the above code.)
P.S.-- If you prefer Walter's mesh plot, you could directly replace surf with mesh in the original post. Equivalently, you could use hc = get(gca, 'Children'); set(hc, 'FacetColor', [1, 1, 1], 'EdgeColor', 'flat') to make a surf look like a mesh.

Accedi per commentare.


Muthu Annamalai
Muthu Annamalai il 28 Lug 2015
You may try to plot the polar plots for X-Y, X-Z, and Y-Z planes, and choose to use decibel (dB) scale or log scale. Read more via,
>> doc polar
>> doc plot3
  1 Commento
mdowney
mdowney il 28 Lug 2015
Hi, Thank you for your response. As I have measurements through the X and Y axis at 10 degree intervals through 360 degrees (a total of 1296 measurements) I would like to represent the measurements obtained through a 360 degree by 360 degree 3 dimensional graph. Similar to the diagram shown. Is this possible do you know?
Many Thanks

Accedi per commentare.


Walter Roberson
Walter Roberson il 29 Lug 2015
You can use a mesh() plot with parametric coordinates.

Categorie

Scopri di più su Polar Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by