SKPS
SKPS

Reputation: 5855

Plotting a 3D data in Matlab

This could be simple question. However, I tried/searched extensively before posting this question.

I have struct called particle and it contains a variable particle(i).center, which is actually a coordinate variable. I am trying to plot those coordinates using plot3 something like,

hold on;
for i=1:np
  plot3(particle(i).center, 'r+')
end

I receive an error message saying the following:

Error using plot3 
Not enough input arguments.

I realize the error is that the variable is passed as 3x1 array instead of 3 comma separated variables. Can anyone suggest, how to plot 3D coordinates as in above case?

Upvotes: 2

Views: 114

Answers (1)

Emerald Weapon
Emerald Weapon

Reputation: 2540

Your particle structure needs to have

particle(i).center.x
particle(i).center.y
particle(i).center.z

and then plot3(particle(i).center.x,particle(i).center.y,particle(i).center.z,...)

Upvotes: 1

Related Questions