変数に応じてplotの色を変更する方法

조회 수: 12 (최근 30일)
Kikuchi
Kikuchi 2024년 1월 26일
이동: Kojiro Saito 2024년 1월 27일
ある変数に応じて2次元プロットの色を変更する方法を教えてください。
例えば、あるGPSの軌跡X(緯度)、Y(経度)のデータと、その時の加速度Zのデータがあります。
X,Yのデータをプロットして、走行軌跡を表示させるときに、
Zの値が+(加速)の時は赤、ー(減速)の時は青といったプロットをしたいです。
また、Zがー(減速)の時のプロットの数はいくつか、自動で算出させたいです。
初心者なので申し訳ありませんが、よろしくお願いします。
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2024년 1월 26일
Could you please show what you have tried yet?
Also, do you want a scatter plot or a line plot?

댓글을 달려면 로그인하십시오.

채택된 답변

Atsushi Ueno
Atsushi Ueno 2024년 1월 26일
이동: Atsushi Ueno 2024년 1월 26일
上記は説明用で、単に2次元でプロットしたいなら下記でOKです。
t = 0:0.01:99.99;
x = sin(2*t);
y = cos(3*t);
z = (sin(8*t) > 0) * 2 - 1;
scatter(x,y,5,z,'filled');
colormap([1,0,0; 0,0,1]);
  댓글 수: 3
Kikuchi
Kikuchi 2024년 1월 26일
ありがとうございます!やりたいことが上手くできました!!
Kikuchi
Kikuchi 2024년 1월 26일
이동: Kojiro Saito 2024년 1월 27일
ありがとうございました。無事に解決できました。

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!