Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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,我有4个向量,前三个是复数,第四个是它们的总和 我用箭袋成功地画出了它们,但是,我需要把第四张画成红色。我怎样才能只把第四个涂成红色 % vectors I want to plot as rows (XSTART, YSTART) (XDIR, YDIR) rays = [ 0 0 real(X1) imag(X1) ; 0 0 real(X2) imag(X2) ; 0 0 real(X3) imag(X3) ; 0 0 real(SUM) imag(SUM)

我有4个向量,前三个是复数,第四个是它们的总和

我用箭袋成功地画出了它们,但是,我需要把第四张画成红色。我怎样才能只把第四个涂成红色

% vectors I want to plot as rows (XSTART, YSTART) (XDIR, YDIR)
rays = [
  0 0   real(X1) imag(X1) ;
  0 0   real(X2) imag(X2) ;
  0 0   real(X3) imag(X3) ;
  0 0   real(SUM) imag(SUM) ;
] ;

% quiver plot
quiver(rays( :,1 ), rays( :,2 ), rays( :,3 ), rays( :,4 ));

% set interval
axis([-30 30 -30 30]);

还是我应该使用plotv

quiver
函数返回的
句柄
不允许访问每个元素以更改其属性,在本例中,颜色

一个可能的解决办法,虽然不是很优雅,但可以是:

  • 绘制整套数据的震颤图
  • 从轴上删除要更改颜色的元素的
    u
    v
    x
    y
    数据
  • 设置
    保持不动
  • 再次绘制整套数据的
    箭袋
  • 从轴上删除不希望更改颜色的元素的
    u
    v
    x
    y
    数据
  • 将所需颜色设置为剩余项
拟议办法的一个可能实施办法是:

% Generate some data
rays = [
  0 0   rand-0.5 rand-0.5 ;
   0 0  rand-0.5 rand-0.5 ;
   0 0  rand-0.5 rand-0.5 ;
] ;
rays(4,:)=sum(rays)

% Plot the quiver for the whole matrix (to be used to check the results
figure
h_orig=quiver(rays( :,1 ), rays( :,2 ), rays( :,3 ), rays( :,4 ));
grid minor
% Plot the quiver for the whole matrix
figure
% Plot the quiver for the whole set of data
h0=quiver(rays( :,1 ), rays( :,2 ), rays( :,3 ), rays( :,4 ));
% Get the u, v, x, y data
u=get(h0,'udata')
v=get(h0,'vdata')
x=get(h0,'xdata')
y=get(h0,'ydata')
% Delete the data of the last element
set(h0,'udata',u(1:end-1),'vdata',v(1:end-1),'xdata', ...
   x(1:end-1),'ydata',y(1:end-1))
% Set hold on
hold on
% Plot again the quiver for the whole set of data
h0=quiver(rays( :,1 ), rays( :,2 ), rays( :,3 ), rays( :,4 ));
% Delete the u, v, x, y data of the element you do not want to change the
% colour
set(h0,'udata',u(end),'vdata',v(end),'xdata', ...
   x(end),'ydata',y(end))
% Set the desired colour to the remaining object
h0.Color='r'
grid minor

希望这有帮助

Qapla'