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