Set xaxis of imagesc with scaled values

87 visualizaciones (últimos 30 días)
Ahmet Hakan UYANIK
Ahmet Hakan UYANIK el 4 de Mayo de 2022
Editada: Adam Danz el 4 de Mayo de 2022
Hi everybody,
I have a matrix(20x400) and I am plotting it with imagesc where y axis having 20 values and xaxis having 400 values.
However, I would like to know how can I scale this xaxis 400 to intervals like between 0:20 = 1, 20:40 = 2 until 380:400 = 20; and setting x axis of imagesc in 0-20 scale with the values of 0-20.
I hope it is clear what I am intended to do.
  1 comentario
DGM
DGM el 4 de Mayo de 2022
Are you just wanting to set the spacing for the ticks, or are you actually wanting a nonuniform spatial scaling?

Iniciar sesión para comentar.

Respuesta aceptada

Adam Danz
Adam Danz el 4 de Mayo de 2022
Editada: Adam Danz el 4 de Mayo de 2022
Specify x and y values using imagesc(x,y,C)
I think this is what you're looking for
C = rand(20,400); % Replace this with your matrix
x = linspace(1,height(C),width(C));
y = 1:height(C);
imagesc(x,y,C)
axis equal % optional
axis tight % optional
Alternatively, use imresize
figure
I = imresize(C,[20,20]);
imagesc(I)
axis equal
axis tight
  6 comentarios
Ahmet Hakan UYANIK
Ahmet Hakan UYANIK el 4 de Mayo de 2022
Excellent, thanks!
Adam Danz
Adam Danz el 4 de Mayo de 2022
Glad it worked out. I'll add the imresize suggestion to the main answer for better visibility.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by