Continuously update MATLAB surf plot and animate it

14 ビュー (過去 30 日間)
Ahmad Lakhani
Ahmad Lakhani 2017 年 9 月 22 日
回答済み: Star Strider 2017 年 9 月 22 日
I have the following loop that plots and re-plots data in MATLAB using thesurf() function. How do I get the plot to update while the values are changing and how do I animate it?
s = 1;
timerID = tic;
while true
if(toc(timerID) > 25)
break;
end
for i=1: 5
removeChannel(session, 7)
addAnalogInputChannel(session,'cDAQ1Mod8',['ai' num2str(i+15)],'Voltage');
for j=1: 5
measurements(6-j,6-i) = abs(session.inputSingleScan) - abs(base);
end
end
surf(interp2(flipud(abs(measurements)),4));
view(0, 90);
colorbar;
pause(0.05)
s = s+1;
end

採用された回答

Star Strider
Star Strider 2017 年 9 月 22 日
I am not certain exactly what you want to do, and I cannot run your code to test this with it.
See if this example offers some idea on how to do what you want:
[X,Y] = meshgrid(linspace(-15, 15, 50));
fcn = @(x,y,k) k*x.^2 + y.^2;
v = [1:-0.05:-1; -1:0.05:1];
for k1 = 1:2
for k2 = v(k1,:)
surfc(X, Y, fcn(X,Y,k2))
axis([-15 15 -15 15 -300 500])
drawnow
pause(0.1)
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by