Normalize plot axes from matrix

Hello, I have a 1x4x10 matrix. I want to plot the values in j-direction vs j-index normalized for different k values. For example,
at k=1, A = [4 3 2 1] If I plot using command
plot (A(1,:,1)
I will get a plot like this:
How can I change the x-axes so it is normalized to 0 to 1 instead 1 to 4?
Thank you

Réponses (1)

Ameer Hamza
Ameer Hamza le 30 Mai 2018

0 votes

You do don't need to change your data, just specify the x values to remain between 0 and 1. For example
A = 1:4;
plot(A);
will give
whereas
A = [1 2 3 4];
x = linspace(0, 1, numel(A))
plot(x, A);
will give
x values varies from 0 to 1

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by