Normalize plot axes from matrix
Show older comments
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
Answers (1)
Ameer Hamza
on 30 May 2018
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
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!