Can I multiply a two different size vectors?

5 visualizzazioni (ultimi 30 giorni)
I have been using vector indexing to plot derivatives as so: vel=diff(pos); plot(t(1:end-1),vel)
I need to multiply the first derivative vector by the second derivative vector but it wont allow me to use vector indexing. Is there an alternative way? Below is my equation. T=J*vel(1:end-1)*acl;
%Coefficients
p1 = 301.59;
p2 = -376.99;
p3 = 125.66;
p4 = 8.5359e-07;
p5 = -4.9784e-08;
p6 = 8.0277e-10;
J = .0537 %kgm^2;
%Equation
pos = p1*t.^5+p2*t.^4+p3*t.^3+p4*t.^2+p5*t+p6;
%%Position vs Time
f1=figure
plot(t,rad)
title('Postition Graph ')
xlabel('Time (s)')
ylabel('Position (rad)')
%%Velocity
f2=figure
vel=diff(pos);
plot(t(1:end-1),vel)
title('Velocity Graph')
xlabel('Time (sec)')
ylabel('Velocity, (m/s)')
%%Acceleration
f3=figure
acl=diff(vel);
plot(t(1:end-2),acl)
title('Acceleration Graph')
xlabel('Time (sec)')
ylabel('Acceleration, (m/s^2)')
%Torque
T=J*vel(1:end-1)*acl;
plot(t(1:end-1),T)
title('Torque')
xlabel('time (s)')
ylabel('Torque (n*m)')
%Power
pwr=J*vel(1:end-1)*acl
plot(t(1:end-2),pwr)
  2 Commenti
Kennedy Oparka
Kennedy Oparka il 11 Feb 2018
Modificato: Kennedy Oparka il 11 Feb 2018
I have added it I am just trying to multiply a 500x1 by a 499x1 vector
Walter Roberson
Walter Roberson il 11 Feb 2018
What size of output are you expecting?

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 11 Feb 2018
Use gradient() instead of diff() to get your numeric derivative.

Più risposte (0)

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by