Hot to change speed to distance?
Show older comments
Hello,
I have array date with time and speeds taken from left and right wheel and I want to calculate distance in simulink. How to do that?
That is my code:

It takes speeds [RPM] from Roboteq Telemetry and adds time from MATLAB Function. 40 [cm] is circumference of a wheels and 75 is gear ratio. So on the output I have now speed [cm/min]. I know that I have to multiply it times time in minutes, but I don't know how.
That how it looks like in workspace:

Minus means that wheel spins backwards so it doesn't matter. Kolums 1-6 is time (year, month, day, hour, minute, second), 7 is left wheel speed and 8 is right wheel speed.
6 Comments
José-Luis
on 3 Aug 2017
What are the units of speed?
How do you intend to account for different left/right wheel speeds?
plaziok
on 3 Aug 2017
José-Luis
on 3 Aug 2017
You could have a look at datenum() and associated functions. It should help you achieve what you want.
Walter Roberson
on 3 Aug 2017
The difference between datetime objects is a duration object that you can use minutes() or seconds() on to extract the time in appropriate units.
berenice va-t-on
on 15 Oct 2017
>> input=rand(1,1000); % Input Training data
>> output= (input>0.5); % Output Training data (returns 1 if input is greater than 0.5)
>> net=patternnet(1) % Create a neural network with 1 hidden layer of with 1 neuron
% patternnet([5 10]) would create 2 hidden layers with 5 and 10 neurons …
>> net=train(net, input, output); % Train neural network
>> net(0.3) % test neural network (close training UI if it opens)
>> net(0.6)
berenice va-t-on
on 15 Oct 2017
load groupA&B.mat
>> [idx,C]=kmeans(lTFaces',10);
>> hFaces=U(:,1:20)*C';
>> imagesc(reshape(hFaces(:,4),[100 100]))
Answers (1)
1 Comment
Walter Roberson
on 4 Aug 2017
You are feeding the date/time information of length 6 together with 2 entries of gain to produce something of length 8. However that might be 8 x 1. Certainly you are not feeding in two dates.
Your problem description says you have times taken from the left and right wheel; it does not then make sense for you to use now() to generate times.
Remember, now() reflects the real-time of running the program, which is not necessarily much related to the simulation time. For example setting a simulation time to picoseconds does not cause Simulink to be able to actually run in picoseconds per iteration. And when you pause in the debugger, does it really make sense for some times to jump massively? You should seldom be reading now() in Simulink; simulation time is more relevant.
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
