フィルターのクリア

How to colormap a 3D trajectory using a 4th array

4 ビュー (過去 30 日間)
Jon
Jon 2014 年 8 月 4 日
コメント済み: Behnam Majd 2022 年 8 月 2 日
Hello Im having some difficulties making a 3D plot, specifically w.r.t. the colormaps
I want to plot a trajectory in 3D using arrays x,y and z. I have a fourth array (a) corresponding to the acceleration at (x,y,z), it has values between [0,1]. I want the trajectory colored using the colormap('jet') based on the acceleration array.
How do I do this

回答 (1 件)

Ashish Gudla
Ashish Gudla 2014 年 8 月 4 日
You can use “scatter3” function to plot your trajectory and also pass the additional arguments, the size of the point and the color of the point (which in your case is the acceleration vector). "scatter3" automatically normalizes the 5th input argument values to the current colormap and uses it.
You can get more information on how to use scatter3 function in the documentation here
Example:
>> t = 0:0.1:10;
>> x = 5*cos(t);
>> y = 5*sin(t);
>> z = sin(t)+cos(t)+t; % A random trajectory
>> a = rand(1,101) %acceleration values generated randomly for example
>> scatter3(x,y,z,5,a)
>> colormap(jet) %change colormap to required the required one
  1 件のコメント
Behnam Majd
Behnam Majd 2022 年 8 月 2 日
owoow that was so helpful , tnx a lot

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by