How to store any sensor's last 1 second's values in workspace as a vector (Real Time mode)?
Show older comments
Hey
e.g.
joy = vrjoystick(1);
x = axis(joy, 1); % This just gives me current value of x-axis of the joystick
But I need a vector which gives me values of 'x' in latest 1 second.
Why I need this? Because one of my matlabscript.m demands values of 'x' in latest 1 second. Not just the current value of x-axis of the joystick.
% So i think there should be something always running in background of Matlab, which can give me recent values of 'x'%.
Thanks
6 Comments
Adam Danz
on 2 Jul 2018
How are you feeding joystick data into Matlab currently?
JAI PRAKASH
on 2 Jul 2018
Edited: JAI PRAKASH
on 2 Jul 2018
Adam Danz
on 2 Jul 2018
I haven't used vrjoystick but I see that it outputs an object that interfaces with your device. I'm assuming the 'joy' output contains sensor data but I'm not sure how that's organized. It's also strange to me that the 'joy' object is being fed into the axis function to produce the current value of the joystick. I'd need to see your code and the plot it produces to help you more.
Nevertheless, would a timer object help you? You could create a timer object that continuously collects joystick data in 1-second loops such that you'll always have the most recent second of data available and you could just sample that 1-second-long vector as needed.
JAI PRAKASH
on 2 Jul 2018
Edited: JAI PRAKASH
on 2 Jul 2018
Walter Roberson
on 2 Jul 2018
axis() is a method of the vrjoystick class
Adam Danz
on 2 Jul 2018
ah.... I see!
Accepted Answer
More Answers (0)
Categories
Find more on Multicore Processor Targets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!