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に2 つのベクトルを持っています。
x = [1 20 3 7 10]
と
y = [2 51 1 9 18]
次のようなそれぞれの値でソートされた値の順序 (1 3 7 10 20) を持つyvs Kをプロットするにはどうすればよいですか?xy
y
x
x = [1 3 7 10 20] y = [2 1 9 18 51]
2 番目の出力引数を指定して 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 で並べ替えることができます