简体   繁体   中英

how to plot column vector data along y-axis in matlab?

I have this row/column vector.

grades = [90, 100, 80, 70, 75, 88, 98, 78, 86, 95, 100, 92, 29, 50];
plot(grades);

In MATLAB, I want to plot grade values along x-axis and indices (1-14) along y-axis. By deafult, indices are plotted along x-axis. How it can be achieved?

grades = [90, 100, 80, 70, 75, 88, 98, 78, 86, 95, 100, 92, 29, 50];
figure;
plot(1:length(grades),grades); % Indices along X
figure;
plot(grades,1:length(grades)); % Indices along Y

If you want to plot data in Matlab. You have to define data sets for all the axis which you are interested in.

In your case, define x-axis data and y-axis data.

So for example your Y axis data would be

grades = [90  100 80 70  75 88 98 78 86 95 100 92 29 50];

for your x data you can use the following.

X = 1:14;

then you have the following plot command

plot(x,grades)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM