image/ imagesc of matrix

조회 수: 45 (최근 30일)
karlo gonzales
karlo gonzales 2012년 5월 23일
이동: DGM 2023년 12월 29일
Hi,
I couldn't figure out how to use "image" or "imagesc" to plot my data, hope you can give me a hint on this issue:
My data consist of collected data over time for several experiments (e.g 100): X1=f(t); ....; X100=f(t)
if i create a matrix as A=[X1;X2;X3;...;X100]; then using " Image(A)" , will give a color plot which y-axis is number of experiments (here 100), x-axis is number of data (length of Xi), and color indicates value of X .
My question:
what i need to do : to change x-axis to value of time, instead of numbering length of X? ( X and Time vector have the same length)
Thanks in advance,

답변 (2개)

Junaid
Junaid 2012년 5월 23일
could you share your code.
For quick answer. You can change the x label by this.
xlabel('This is the label caption');
and if you want to change the Ticks values, then ;
set(gca,'XTick',[1:5]);% something like this
in above command, your X tick values will be from 1 to 5, you can set as you like.
  댓글 수: 2
karlo gonzales
karlo gonzales 2012년 5월 23일
이동: DGM 2023년 12월 29일
Hi,
Thanks Junaid for your reply. but it doesn't work that way. consider
A=randn(100,200); T=linespace(1,10,200); imagesc(A)
set( gca,'XTick', T );
will not generate the image i was looking for! or maybe i misunderstood your suggestion.
Junaid
Junaid 2012년 5월 23일
이동: DGM 2023년 12월 29일
A=randn(100,200); T=linspace(1,40,200);
imagesc(A)
datefmt = 'HH:MM'; %adjust as appropriate
xticks = 1:20:200; %adjust as appropriate, positive integers only
xlabels = cellstr( datestr( T(xticks), datefmt ) ); %time labels
% xlabels = num2str( ( T(xticks)) ); % you don't need this
set(gca, 'XTick', 1:20:200, 'XTickLabel', xlabels);
Now try, as you were contaminating the xlabels. I hope this works now.

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


Walter Roberson
Walter Roberson 2012년 5월 23일
datefmt = 'HH:MM'; %adjust as appropriate
xticks = 1:10:100; %adjust as appropriate, positive integers only
xlabels = cellstr( datestr( MyTimeVector(Xticks), datefmt ) ); %time labels
set(gca, 'XTick', 1:10:100, 'XTickLabel', xlabels);
  댓글 수: 1
karlo gonzales
karlo gonzales 2012년 5월 23일
이동: DGM 2023년 12월 29일
unfortunately, still i couldn't get the good result from the cods
A=randn(100,200); T=linspace(1,40,200);
imagesc(A)
datefmt = 'HH:MM'; %adjust as appropriate
xticks = 1:20:200; %adjust as appropriate, positive integers only
xlabels = cellstr( datestr( T(xticks), datefmt ) ); %time labels
xlabels = num2str( ( T(xticks)) );
set(gca, 'XTick', 1:20:200, 'XTickLabel', xlabels);
any idea, what's wrong here?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by