Continuously update MATLAB surf plot and animate it
조회 수: 12 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!