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

回答(1 个)

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

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

提问:

2018-5-30

Community Treasure Hunt

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

Start Hunting!

Translated by