0
저는 회로 공학 프로젝트를 위해 MATLAB을 Arduino와 인터페이스하고 있습니다. 나는 주어진 센서에서 감지하는 전압에 대해 Arduino를 폴링하고, 그 전압을 벡터에 추가 한 다음 루프 동안 동일한 루프 내에서 모두 그려 봅니다. 나는 처음 두 부분을 가지고 있지만, 오랜 시간이 경과함에 따라 전압 벡터를 반복해서 그려 보는 방법을 알아낼 수 없다. 이것을 할 수있는 방법이 있습니까? plot
줄 끝에서 drawnow
을 추가while 루프에서 변경 벡터를 플로팅하는 MATLAB
%{
Ventilation Rate Sensor v0.1
This program uses a thermistor connected to pin A0 and analyzes the
difference in voltage drop in order to assess the user's ventilation rate.
Designed for use with a voltage divider using a 2.2kOhm resistor and a
10kOhm (at 25C) thermistor in series. Note that this REQUIRES the Arduino
to have the code for MATLAB interface already installed. This is included
in the MATLAB Arduino software page at
<<http://www.mathworks.com/matlabcentral/fileexchange/
32374-matlab-support-package-for-arduino-aka-arduinoio-package>>
%}
clc
clear
close all
ard = arduino('COM3');
voltage = [];
timer = datenum(clock+[0,0,0,0,0,30]);
while datenum(clock) < timer
sensorValue = ard.analogRead(0);
voltage = [voltage (sensorValue * (5/1023))];
hold on;
t = [1:1:length(voltage)];
plot(t,voltage)
end
고마워요! 이것은 정말 잘 작동합니다. – SciurusDoomus
@SciurusDoomus 도움이 된 것을 기쁘게 생각합니다. 또한 유용 할 수있는 다른 아이디어가있는 편집 된 답변 –
흥미 롭습니다. 플로팅은 출력하고자하는 실제 데이터보다 테스트 메커니즘에 더 가깝기 때문에 실행 시간을 줄일 필요가 없습니다. 그러나 앞으로 필요할 것이거나이 프로그램을 정말로 오래된 시스템에서 사용 가능하게 만들 것이라고 확신합니다. 감사! – SciurusDoomus