handle
返回quiver
函数不允许访问每个单个元素,以便更改其属性,在这种情况下,颜色。
一个可能的解决办法,虽然不完全是优雅的,可能是:
- 情节颤动整个数据集的
- 从轴取出的
u
,v
,x
和y
数据元素你想改变颜色
- 设置
hold on
- 情节再次
quiver
对整个数据集 的
- 从轴取出
u
,v
,元素的x
和y
数据,你不想改变颜色
- 所需的颜色设置为remainig项目
一可能实施方案提出的方法可能是:
% 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
希望这会他lps,
Qapla'