0. MATLAB真實航母基本的工具,其中的函數/工具不計其數,而且有些函數/工具非常的炫酷。在MATLAB第四篇章把平時工作中用到的些許函數進行使用的講解
主題1.:drawnow
解釋:更新圖窗並處理回調
說明:drawnow更新圖窗並處理任何掛起的回調。如果您修改圖形對象並需要在屏幕上立即查看此次更新,請使用該命令。這就是把圖形更新的過程進行動態的流數據的動畫。
后面有幾個方法:
方法1.limitrate,更新數量限制為每秒20幀。如果上次更新后不到50毫秒,則會丟棄新的更新
方法2:nocallbacks,會延遲回調,知道下一個完整的命令。
方法3:limitrate nocallbacks降序局更新限制為每秒20幀
方法4:update會跳過更新並延遲回調(不建議)
方法5:expose,更新窗口延遲(不建議)
主題2:addpoints
解釋:向動畫線條中添加點
說明:
addpoints(an,x,y) % 二維的
addpoints(an,x,y,z) % 三維的,
an:指定動畫線條中添加x和y的點
主題3:animatedline
解釋:創建動畫線條
說明:
an = animatedline
an = animatedline(x,y)
an = animatedline(x,y,z)
an = animatedline(___,Name,Value)
an = animatedline(ax,___)
因此:主題1,主題2,主題3可以結合起來組成一個使用
% 首先創建動畫線條
h = animatedline('LineStyle','-.','LineWidth',0.01,'Marker','>','Color','r');
% 確定x,y
x = linspace(0,4*pi,10000);
y = cos(x);
% 進行循環畫圖上的點
for k = 1:10000
addpoints(h,x(k),y(k));
%動畫
drawnow update % 快速更新前面的點
end
drawnow
% 可以標注時間段的方式
% 首先創建動畫線條
h = animatedline('LineStyle','-.','LineWidth',0.01,'Marker','>','Color','r');
% 確定x,y
x = linspace(0,4*pi,10000);
y = cos(x);
a = tic; % start timer
% 進行循環畫圖上的點
for k = 1:10000
addpoints(h,x(k),y(k))
b = toc(a); % check timer
if b > (1/10)
drawnow % update screen every 1/30 seconds
a = tic; % reset timer after updating
end
end
drawnow

好有意思的動態圖示。其實還有一些常用的。后面有機會再說
主題4:gepoints(h)
獲取返回線條中的點
h = animatedline(1:10,1:10);
[x,y] = getpoints(h)
x = 1×10
1 2 3 4 5 6 7 8 9 10
y = 1×10
1 2 3 4 5 6 7 8 9 10
