【发布时间】:2021-11-29 08:06:51
【问题描述】:
我有一个 appdesigner 应用程序,其中来自两个传感器的数据通过 Arduino 实时绘制。这些传感器是:超声波传感器和光传感器。 appdesigner 中的应用程序通过 Arduino Uno 读取数据并将数据绘制到 UIAxes 组件中。
应用的私有属性:
properties (Access = private)
a;
h;
h2;
h3;
btnSt = 0;
initialTime = 2;
end
应用执行时配置 Arduino 的代码:
function startupFcn(app)
movegui(app.UIFigure, "center")
app.a = arduino;
app.a.configurePin('A0', 'AnalogInput');
app.a.configurePin('A1', 'AnalogInput');
end
按下按钮时读取和绘制 UIAxes 中的数据的代码:
function StartPushed(app, event)
cla(app.UIAxes, "reset");
cla(app.UIAxes2, "reset");
app.h = animatedline(app.UIAxes, "Color", "Black");
app.h2 = animatedline(app.UIAxes2, "Color", "Black");
start = 1;
% stops the app when the stop button is pressed
while app.btnSt == 0
fotoRes = readVoltage(app.a, 'A0');
distance = readVoltage(app.a, 'A1');
distCm = (3027.4/distance)^1.2134;
tp = app.initialTime - start;
% plot the data of the light sensor
addpoints(app.h, tp, fotoRes);
% plot the data of the ultrasonic sensor
addpoints(app.h2, tp, distCm);
drawnow
app.initialTime = app.initialTime + 1;
end
end
总之,有没有办法从 Matlab Web 应用程序服务器做同样的事情?当然,在实时获取数据的条件下。 任何帮助表示赞赏。
【问题讨论】:
标签: matlab plot arduino matlab-deployment