简体   繁体   English

MATLAB Plot:修改y平面上的点位置

[英]MATLAB Plot: modifying point position on y plane

I have this line of code in MATLAB, which sets these vectors: 我在MATLAB中有以下代码行,它设置了这些向量:

x = [2 12 3 8 1 9 2; -3 -2 -1 0 1 2 3]
x =
 2  12  3  8  1  9  2
-3  -2 -1  0  1  2  3

Considering the first row as points in y-plane and second row as x-axis in MATLAB plot 在MATLAB图中将第一行视为y平面上的点,将第二行视为x轴

Now what line of code in MATLAB will take the maximum number in the first row and set at the middle(0) point in x-axis which will make it look like this 现在,MATLAB中的哪一行代码将在第一行中获取最大数量,并设置为x轴的中点(0),这将使其看起来像这样

x =
 9   2  2  12 3  8  1
-3  -2 -1  0  1  2  3

Please any idea is appreciated, I don't know how best to ask this question, I'm actually trying to edit a plot in MATLAB. 请欣赏任何想法,我不知道如何最好地问这个问题,我实际上是在尝试在MATLAB中编辑图。

Code: 码:

x = [2 12 3 8 1 9 2; -3 -2 -1 0 1 2 3];
[~,idx] = max(x(1,:));
x(1,:) = circshift(x(1,:),[0 (length(x)+1)/2-idx]);

Output: 输出:

x =

     9     2     2    12     3     8     1
    -3    -2    -1     0     1     2     3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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