image/ imagesc of matrix

47 visualizaciones (últimos 30 días)
karlo gonzales
karlo gonzales el 23 de Mayo de 2012
Movida: DGM el 29 de Dic. de 2023
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,

Respuestas (2)

Junaid
Junaid el 23 de Mayo de 2012
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 comentarios
karlo gonzales
karlo gonzales el 23 de Mayo de 2012
Movida: DGM el 29 de Dic. de 2023
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 el 23 de Mayo de 2012
Movida: DGM el 29 de Dic. de 2023
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.

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 23 de Mayo de 2012
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 comentario
karlo gonzales
karlo gonzales el 23 de Mayo de 2012
Movida: DGM el 29 de Dic. de 2023
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?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by