how to plot in three dimension (3D)

Hi, I am trying to do a 3D plot for 18 by 18 matrix containing a first structure "positions" (x,y coordinates), and a second structure containing "power" in db. I have about 20 files with the position and power structures in each file. I took all the positions from each file and put them in one single structure and the power in another structure. However, the positions repeat after 324 rows (18 X18 = 324). when i tried to plot, i got weird plot. Not sure why, but i am thinking when the positions repeat, the graph does not look right. below is the code i used to do the plot.
load('combine.mat');
Pow=positions.offsetdata;
Pos=[]; for i=1:length(power.positions); Poss=power.positions{i,1}; Pos=[Pos;Poss']; end
figure plot3(Pos(:,1),Pos(:,2),Pow)

Answers (1)

You should be considering using cell2mat() instead of looping putting the data together like that.
When you put the data together like that, there would be no breaks between layers.
What is the size() of Pow ?

4 Comments

i tried to use mesh but it get this error "Z must be a matrix, not a scalar or vector".
You are trying to create a 3D plot with repeated x and y. That sounds like you have implicit z coordinates according to which file it is. If that is the case then each point implicitly has x, y, z, and power. That would require a 4D plot, or a 3D plot with color. However, a 3D plot with color usually has difficulty in allowing you to look "into" the plot.
The size of Power is 1296
Please clarify about whether you have implicit z coordinates or if the power is to be your z coordinate. If the power is to be your z coordinate then are the different files taken at different times and you need to create an animation?

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Asked:

Ray
on 5 Oct 2015

Commented:

on 5 Oct 2015

Community Treasure Hunt

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

Start Hunting!