필터 지우기
필터 지우기

colour code plotted data according to column

조회 수: 2 (최근 30일)
Yuchun Ding
Yuchun Ding 2022년 4월 11일
댓글: Yuchun Ding 2022년 4월 11일
I have a 20000*20 matrix of data and I'd like to colour code the points depends on the column. e.g. data points from column one are blue, from column two are red...etc all the way to column 20.
I saw similiar answer from this post but for-loop doesn't work well for large amount of data points
I wonder if this can be done more efficiently?

답변 (1개)

Riccardo Scorretti
Riccardo Scorretti 2022년 4월 11일
Simply like that, if I correclty understand your question:
% Generate some data
p = linspace(0, 2*pi, 20000);
data = zeros(numel(p), 20);
for n = 1 : 20
data(:,n) = n*sin(p);
end
figure
plot(data);
  댓글 수: 1
Yuchun Ding
Yuchun Ding 2022년 4월 11일
that was quick! Thanks a lot!
not exatly what I meant but you inspired me to find the right answer: plot and hold on the data column by column where data points from each column are assigned a colour of my choice. By default I think matlab colour code them using jet colourmap.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by