Continuously update MATLAB surf plot and animate it

14 vues (au cours des 30 derniers jours)
Ahmad Lakhani
Ahmad Lakhani le 22 Sep 2017
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

Réponse acceptée

Star Strider
Star Strider le 22 Sep 2017
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

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by