Realtime streaming in Simulink?
Ältere Kommentare anzeigen
Greetings,
I have this project I am tinkering with that I need to understand what are the requirments in terms of software from MathWorks.
Tonight, I was attempting to stream mobile sensor data (via the MathWorks App) into Simulink. I wrote a script in MatLab that I think might do the trick. The goal was to "subscribe" to the Azimuth value for further play using a servo. The goal would be that the servo would ultimatley keep the same heading/position as I rotated the phone on my desk.
To start, I made a simple model with constant block the would grab the variable from my workspace and then I was trying to use a display block to see the values as I rotate the phone. But it never updates?
Do I need to buy the Simulink Realtime Desktop?
function streamAzimuth()
m = mobiledev;
m.OrientationSensorEnabled = true;
m.Logging = true;
fprintf("Streaming azimuth data...\n");
while true
orientationData = orientlog(m);
if ~isempty(orientationData)
azimuth = orientationData(end, 2);
assignin("base", "currentAzimuth", azimuth(end));
else
assignin("base", "currentAzimuth", NaN);
end
pause(0.1);
end
end
2 Kommentare
Walter Roberson
am 15 Nov. 2024
How exactly are you using the currentAzimuth base workspace variable in Simulink ?
Clayton Allen
am 15 Nov. 2024
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Sources finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!