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 Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by