How to change the imagesc axis?
    110 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Kalasagarreddi Kottakota
 il 10 Mar 2023
  
    
    
    
    
    Modificato: Simon Chan
      
 il 10 Mar 2023
            I have he following code which displays imagesc axis with the length of the samples. But I want the x axis to be dispyed w.r.t time t. Can some one help me regarding this?
clear all; close all;
t= 0:0.1:1;
N = length(t);
M = randn(N,N);
figure()
imagesc(M);
0 Commenti
Risposta accettata
  Dyuman Joshi
      
      
 il 10 Mar 2023
        You can specify the x and y ranges and then add ticks for all values of t
t= 0:0.1:1;
N = length(t);
M = randn(N,N);
figure()
imagesc([t(1) t(end)], [1 N], M)
xticks(t)
0 Commenti
Più risposte (1)
  Simon Chan
      
 il 10 Mar 2023
        Use function xticklabels
clear all; close all;
t= 0:0.1:1;
N = length(t);
M = randn(N,N);
figure()
imagesc(M);
ax=gca;
xticklabels(ax,t(ax.XTick));
2 Commenti
  Simon Chan
      
 il 10 Mar 2023
				
      Modificato: Simon Chan
      
 il 10 Mar 2023
  
			Suppose you would like to roundoff to 2 decimal places.
clear all; close all;
t= 0:1/6:1;
N = length(t);
M = randn(N,N);
figure()
imagesc(M);
ax=gca;
xticklabels(ax,round(100*t(ax.XTick))/100);
Or if you want to show all TickLabels to have 2 decimal places.
figure()
imagesc(M);
ax=gca;
xticklabels(ax,compose('%.2f',round(100*t(ax.XTick))/100));
Vedere anche
Categorie
				Scopri di più su LabVIEW in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!








