Looking to plot a function in 3D

조회 수: 3 (최근 30일)
Sam
Sam 2013년 12월 27일
댓글: Image Analyst 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