Looking to plot a function in 3D

I have a function type1 which returns to me an output in the form of a 3x1 matrix for an input t
X=[x y z]
The components of X, (x,y,z) are for a point in 3d space.
I'm looking to plot all the possible X values on one figure for 0<t<360.
I've tried looking at the surf and mesh function, not quite sure how to get it to work.
plot3(X(1),X(2),X(3),'.');
grid on
The above presents just one point in 3d space.
function [ X ] = type1b(t)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
%Definition of variables (most will be variable)
qr1=[0,0,1]; %Axis of rotation of link 1 (v)
qr2=[0,0,1]; %Axis of rotation of link 2 (v)
H1=[1,0,0]; % Link 1 (v?)
H2=[1,0,0]; % Link 2 (v?)
; %Angle of rotation
U1=[cos(t/2),sin(t/2)*qr1]; %quaternion rotor for link 1
U2=[cos(t/2),sin(t/2)*qr2]; %quaternion rotor for link 2
Ug=U1; %Globalising Quaternion (v)
H2g=quatrotate(Ug,H2); %Globalised H2
X=quatrotate(U1,H1)+ quatrotate(U2,H2g); %+d;
plot3(X(1),X(2),X(3),'.');
grid on

Respuestas (1)

Image Analyst
Image Analyst el 27 de Dic. de 2013
What about
plot3(x, y, z, '.');
??? You said you had x, y, and z - that's how you constructed X, right? So just plot them.

3 comentarios

Image Analyst
Image Analyst el 27 de Dic. de 2013
Editada: Image Analyst el 27 de Dic. de 2013
for t = 0:360 % Get all values of x, y, and z.
[x(t), y(t), z(t)] = type1();
end
plot(x, y, z, '.');
Sam
Sam el 27 de Dic. de 2013
Could you take a look at my edited question, it includes my lines of code.
How can I fit the for loop in this?
I think the best way to do this would be for the function type1b to add a new 3x1 row to a matrix, lets call it B, for each loop. So that there is a 3x360 matrix which I can then plot. What do you think? How could I do that?
Image Analyst
Image Analyst el 27 de Dic. de 2013
How did you call it? What is the value of "t"?

Iniciar sesión para comentar.

Productos

Etiquetas

Preguntada:

Sam
el 27 de Dic. de 2013

Comentada:

el 27 de Dic. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by