Info

此问题已关闭。 请重新打开它进行编辑或回答。

whenever i run the program it says 'Error using interpDriveCycle (line 10) Not enough input arguments. '

1 次查看(过去 30 天)
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

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by