Plot velocity vector vs time
Afficher commentaires plus anciens
Hi there,
I have the following task and I don't know how to implement it:

So I have the general solution for the vector
v(t)=(u(t); v(t); w(t))
which is
v=-inv(phiRV)*phiRR*dr0
where phiRV, phiRR are time-dependent 3x3-matrices and dr0 is another 3x1-vector.
Now I have to calculate v for each t=1:1200:1200.
As you can guess, so far I haven't succeeded. One problem is that I don't really have an idea what the plot should look like, I have never done something like this before. And then there's the implementation code-wise, of course.
I hope you can help me with that, thank you! :)
Réponses (1)
Image Analyst
le 1 Oct 2017
You don't do this:
t=1:1200:1200;
you do this:
t=1:1200;
Then to plot v vs. t, do this:
plot(t, v, 'b-', 'LineWidth', 2);
grid on;
title('v vs. t', 'FontSize', 20);
xlabel('t', 'FontSize', 20);
ylabel('v', 'FontSize', 20);
Assuming your equation for v is really delta v. Otherwise we need to know what the delta is from, like v(0) or is it the prior v, like you'd get from diff(v).
4 commentaires
Backtobasics
le 1 Oct 2017
Image Analyst
le 1 Oct 2017
Modifié(e) : Image Analyst
le 1 Oct 2017
Please give the full code so I can run it, including where you define dr and n. Also, you'll need to define t before you use it in line 2.
Here's some attempt with made up values:
t=1:1200;
dr = [1;2;3];
n = 2
dr0=dr;
dv0 = zeros(length(t), 3);
for k = 1 : length(t)
this_t = t(k);
phiRV=[1 /n *sin(n*this_t), 2 / n * (1-cos(n*this_t)), 0; ...
2 / n * (cos(n*this_t)-1), 1 / n * (4*sin(n*this_t)-3*n*this_t), 0; ...
0 0 1 / n * sin(n*this_t)];
phiRR = [4 - 3*cos(n*this_t), 0, 0; ...
6*(sin(n*this_t) - n*this_t), 1, 0; ...
0, 0, cos(n*this_t)];
dv0(k, :) = -inv(phiRV) * phiRR * dr0;
end
% Plot second column
plot(t, dv0(:, 2), 'b-', 'LineWidth', 2);
grid on;
title('delta v vs. t', 'FontSize', 20);
xlabel('t', 'FontSize', 20);
ylabel('Delta v', 'FontSize', 20);

Backtobasics
le 1 Oct 2017
Backtobasics
le 1 Oct 2017
Modifié(e) : Backtobasics
le 1 Oct 2017
Catégories
En savoir plus sur Code Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

