Code covered by the BSD License  

Highlights from
3D colored line plot

4.5

4.5 | 2 ratings Rate this file 11 Downloads (last 30 days) File Size: 1.47 KB File ID: #23566
image thumbnail

3D colored line plot

by Georg Stillfried

 

06 Apr 2009 (Updated 22 Oct 2009)

Plot 3D lines with CData, (actually surface)

| Watch this File

File Information
Description

plots a 3-D "line" with c-data as color
Makes a surface object and the colouring is controlled by the colormap.

Example:
v_start = [2 1 8]; % m/s
g = 9.81; % m/(s^2)
t_impact = 2*v_start(3)/g; % s
t = [0:t_impact/100:t_impact]'; % s
x = v_start(1)*t; % m
y = v_start(2)*t; % m
z = v_start(3)*t-1/2*g*t.^2; % m
velocity = ([[x(2:numel(t)) y(2:numel(t)) z(2:numel(t))]-[x(1:numel(t)-1) y(1:numel(t)-1) z(1:numel(t)-1)];[0 0 0]]); % m/s
speed = sqrt(sum(velocity.^2,2)); % m/s
color_line3(x,y,z,speed);
axis equal vis3d; view(15,15);
title('trajectory of a projectile, color = speed');
axis equal vis3d; view(15,15);
colorbar

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Colored line or scatter plot

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
29 Jan 2010 Ward verhelst

great stuff,..thanks a lot

08 Apr 2010 James Edwards

works perfectly, thanks!

21 Jul 2011 Adam Nieslony  
Please login to add a comment or rating.
Updates
14 Apr 2009

Added example

14 Apr 2009

add filename to title

22 Oct 2009

removed "scatter" from title

Tag Activity for this File
Tag Applied By Date/Time
cdata Georg Stillfried 06 Apr 2009 11:31:26
color line Georg Stillfried 06 Apr 2009 11:31:26
graphics Georg Stillfried 06 Apr 2009 11:31:26
lines Georg Stillfried 06 Apr 2009 11:31:26
object Georg Stillfried 06 Apr 2009 11:31:26
plot Georg Stillfried 06 Apr 2009 11:31:26
plot3 Georg Stillfried 06 Apr 2009 11:31:26
3d Georg Stillfried 06 Apr 2009 11:31:26
specialized Georg Stillfried 06 Apr 2009 11:31:26
surface Georg Stillfried 06 Apr 2009 11:31:26
plotting Georg Stillfried 06 Apr 2009 11:31:26
color_line3 Georg Stillfried 14 Apr 2009 07:52:35
3d Glenn 10 Nov 2009 15:39:46
3d Raghavendra Akula 26 Mar 2012 05:50:15

Contact us at files@mathworks.com