whenever i run the program it says 'Error using interpDriveCycle (line 10) Not enough input arguments. '
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
function [a,s] = interpDriveCycle(t, v)
%interpDriveCycle Produce accelerations that go with drive cycles.
% a = interpDriveCycle(t, v) produces a constant acceleration to go with
% the drive cycle data described by (t, v). A constant acceleration is
% assumed between each point in the cycle.
% Check input parameters:
assert(isvector(t), 'interpDriveCycle:inputsNotVectors', ... 'Inputs not vectors: t and v must be row or column vectors.');
sizeT = size(t);
sizeV = size(v);
sizesAreEqual = isequal(sizeT, sizeV);
assert(sizesAreEqual, 'interpDriveCycle:inputSizesNotEqual', ... 'Input sizes not equal: t and v must have the same dimensions.');
% Convert to column vector form:
t = t(:);
v = v(:);
% Calculate the accerations:
deltaT = [t(2:end) - t(1:end-1); 1];
deltaV = [v(2:end) - v(1:end-1); 0];
a = deltaV ./ deltaT;
% Calculate the displacements.
s = zeros(size(t));
for iPoint = 1:numel(s)-1
thisS = s(iPoint);
thisV = v(iPoint);
thisA = a(iPoint);
deltaT = t(iPoint+1)-t(iPoint);
nextS = thisS + thisV * deltaT +0.5*thisA*deltaT*deltaT;
s(iPoint+1)= nextS;
end
a = reshape(a, sizeT);
s = reshape(s, sizeT);
end
1 commentaire
Robert Fennis
le 12 Juil 2016
Same as in the previous case. What are you trying to do?
Réponses (0)
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!