請幫我解決這個問題。該圖給出正在移動的移動用戶。現在,我試圖在圖中添加一些常數點。就像移動用戶的基站一樣。我想爲每個基站說一個'#',並把它們放在10個左右。編輯一個恆定節點的隨機航點移動性matlab
function test_Animate(s_mobility,s_input,time_step)
v_t = 0:time_step:s_input.SIMULATION_TIME;
for nodeIndex = 1:s_mobility.NB_NODES
%Simple interpolation (linear) to get the position, anytime.
%Remember that "interp1" is the matlab function to use in order to
%get nodes' position at any continuous time.
vs_node(nodeIndex).v_x = interp1(s_mobility.VS_NODE(nodeIndex).V_TIME,s_mobility.VS_NODE(nodeIndex).V_POSITION_X,v_t);
vs_node(nodeIndex).v_y = interp1(s_mobility.VS_NODE(nodeIndex).V_TIME,s_mobility.VS_NODE(nodeIndex).V_POSITION_Y,v_t);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure;
hold on;
for nodeIndex = 1:s_mobility.NB_NODES
vh_node_pos(nodeIndex) = plot(vs_node(nodeIndex).v_x(1),vs_node(nodeIndex).v_y(1),'*','color',[0.3 0.3 1]);
end
title(cat(2,'Simulation time (sec): ',num2str(s_mobility.SIMULATION_TIME)));
xlabel('X (meters)');
ylabel('Y (meters)');
title('Random Waypoint mobility');
ht = text(min(vs_node(1).v_x),max(vs_node(1).v_y),cat(2,'Time (sec) = 0'));
axis([min(vs_node(1).v_x) max(vs_node(1).v_x) min(vs_node(1).v_y) max(vs_node(1).v_y)]);
hold off;
for timeIndex = 1:length(v_t);
t = v_t(timeIndex);
set(ht,'String',cat(2,'Time (sec) = ',num2str(t,4)));
for nodeIndex = 1:s_mobility.NB_NODES
set(vh_node_pos(nodeIndex),'XData',vs_node(nodeIndex).v_x(timeIndex),'YData',vs_node(nodeIndex).v_y(timeIndex));
end
drawnow;
end
末
的這個完整的提交可以在The MathWorks公司的網站上得到。 http://www.mathworks.in/matlabcentral/fileexchange/30939-random-waypoint-mobility-model
請幫我一把。
我是否錯過了某些明顯的東西?因爲你的觀點正在移動的唯一原因是他們被'set'改變了,所以沒有什麼能阻止你添加一組你不更新的固定位置。 – nkjt
確切的,但我在哪裏添加該設置?因爲,我試着在幾個地方添加它,我觀察到所有的點都不動。你能告訴我,我可以在哪裏添加套餐? – user3222664
根本不需要添加'set' - 僅在代碼中使用'set'來移動點。你需要第二個'plot'命令來添加固定點。我會用最小的繪圖示例來回答。 – nkjt