Looking to plot a function in 3D

3 次查看(过去 30 天)
Sam
Sam 2013-12-27
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

回答(1 个)

Image Analyst
Image Analyst 2013-12-27
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 个评论
Sam
Sam 2013-12-27
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 2013-12-27
How did you call it? What is the value of "t"?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by