How to take time, angle and speed and plot them to see the course taken?

So I was given a csv file that gives me Time (s), Angle (rad), and Speed (m/s). Here is what I have to do with it:
The data for time, angle, and speed are uniform random values, with directions splattered around the compass. Working from dead reckoning, and assuming an initial position of (0, 0), determine the mean x-displacement, the mean y-displacement, and plot the course taken.
I'm not sure how to do this.
Can anybody help?

1 Comment

If you have some idea on how to get started, then I suggest you post the code that you have written, and tell us where you are stuck. Maybe we can give you a boost.
If you really have no idea how to start, then I recommend that you go to your instructor and tell them that, and get some help from them.

Sign in to comment.

Answers (2)

Did you try csvread() and plot() or scatter()? And mean()? Something like:
dataTable = csvread(fullFileName);
% Compute x,y from dataTable, then...
meanOfX = mean(x);
meanOfY = mean(y);
plot(x, y, 'r0-');
But you need to convert your speed and angle into x and y coordinates using regular trigonometry. In a for loop:
x(k) = x(k-1) + speed(k) * cos(angleInRadians(k));
y(k) = y(k-1) + speed(k) * sin(angleInRadians(k));
That's plenty of hints - probably too many. Give it a try yourself. If it's homework, the protocol is for you to tag your question as homework (I did it for you).

1 Comment

I started with this:
clear,clc,clf
D = importdata('hw8_data.csv');
time = D.data(:,1);
angle = D.data(:,2);
speed = D.data(:,3);
r = speed.*time;
[X,Y] = pol2cart(angle,r);
plot(X,Y)
But this doesn't give me the "course" that the instructor is looking for.
So to convert speed and angle using a for loop would I start k at k=0?

Sign in to comment.

hi, I think you should use plot3 :
plot3(time,position,velocity)
As the initial position is mentioned , i think you have to integrate the velocity
so explain more as it asks for (x,y) mean directions, what is your data Nx3 matrix or Nx5 as t x y vx vy ?

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 8 Feb 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!