Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在MATLAB中有两个向量,比如:
x = [1 20 3 7 10]
和
y = [2 51 1 9 18]
我如何绘制yvs Kx的排序值顺序(1 3 7 10 20),它们各自y的值如下所示?
y
x
x = [1 3 7 10 20] y = [2 1 9 18 51]
使用第二个输出参数调用 sort。
x = [1 20 3 7 10] y = [2 51 1 9 18] [xsorted, I] = sort(x) ysorted = y(I)
XY = sortrows([x ; y]'); plot(XY(:,1), XY(:,2));
连接矩阵,转置它们,然后您可以使用 sortrows 按 X 排序