Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MATLAB有序绘图_Matlab_Plot - Fatal编程技术网

MATLAB有序绘图

MATLAB有序绘图,matlab,plot,Matlab,Plot,我有两个向量,比如: 及 如何绘制yvs K,其中x具有排序的值顺序(1 3 7 10 20),其各自的y值如下所示 x = [1 3 7 10 20] y = [2 1 9 18 51] 连接矩阵,转置它们,然后可以使用sortrows按X排序,并使用第二个输出参数调用sort x = [1 20 3 7 10] y = [2 51 1 9 18] [xsorted, I] = sort(x) ysorted = y(I) x = [1 3 7 10 20] y = [2 1 9

我有两个向量,比如:

如何绘制
y
vs K,其中
x
具有排序的值顺序(1 3 7 10 20),其各自的
y
值如下所示

x = [1 3 7 10 20]
y = [2 1 9 18 51]

连接矩阵,转置它们,然后可以使用sortrows按X排序,并使用第二个输出参数调用sort

x = [1 20 3 7 10]  
y = [2 51 1 9 18]  

[xsorted, I] = sort(x)
ysorted = y(I)
x = [1 3 7 10 20]
y = [2 1 9 18 51]
XY = sortrows([x ; y]');

plot(XY(:,1), XY(:,2));
x = [1 20 3 7 10]  
y = [2 51 1 9 18]  

[xsorted, I] = sort(x)
ysorted = y(I)