image/ imagesc of matrix
31 次查看(过去 30 天)
显示 更早的评论
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,
0 个评论
回答(2 个)
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 个评论
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
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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!