Unrecognized function or variable 'FirstDerivative'
显示 更早的评论
Hi guys,
I'm having trouble with a MATLAB script given to me by my honours supervisor and I need this data analysed by Friday for my final presentation.
The error message I receive is the following on line 76 (highlighted in bold below)
Unrecognized function or variable 'FirstDerivative'.
Error in ImpactAnalysis (line 76)
acceleration(:, footwear, site, trial) = FirstDerivative(velocity(:, footwear,
site, trial), 5000, 100, .0004);
When I change the 'FirstDerivative' function to 'diff' I then get this error:
Error using diff
Too many input arguments.
Error in ImpactAnalysis (line 76)
acceleration(:, footwear, site, trial) = diff(velocity(:, footwear, site, trial),
5000, 100, .0004);
Please help, I need this data to pass my Honours unit.
_____________________________________________________________________________________________________
load ..\ImpactTestFiles\Calibration\gain.txt
%load ImpactData.mat
for footwear = 1 %1:4
for site = 1 %:2
for trial = 1:1
XlsFilename = ['C:\Users\Julian\Desktop\ImpactTestFiles\RawData\' char(FootwearName(footwear)) char(ShoeSite(site)) num2str(trial) 'ScaledData.xlsx'];
data = xlsread(XlsFilename);
display(['Calculating for ' char(FootwearName(footwear)) char(ShoeSite(site)) num2str(trial)])
% Find beginning and end of impact data
InitialForce = mean(data(1:100, 2));
InitialForceSD = std(data(1:100, 2));
InitialPosition = mean(data(1:100, 3));
% Find initial
count = 1;
while data(count, 2) < 500
count = count + 1;
end
FirstTry = count - 1;
count = FirstTry;
while data(count, 2) > InitialForce + 20
count = count - 1;
end
InitialStrikeTiming = count - 2;
StartData = InitialStrikeTiming - 100;
EndData = InitialStrikeTiming + 500;
ImpactData = (data(StartData:EndData, :));
force(:, footwear, site, trial) = ImpactData(:, 2);
figure(1);clf;hold on;plot(force(:, footwear, site, trial));plot(100, force(100, footwear, site, trial),'m*');pause
position(:, footwear, site, trial) = smoothit(ImpactData(:, 3), 5000, 100) / 1000;
% [DataDerivatives] = DisVelAcc(position(:, footwear, site, trial), 5000);
% velocity(:, footwear, site, trial) = DataDerivatives.vel;
velocity(:, footwear, site, trial) = smoothit(ImpactData(:, 4), 5000, 400) / 1000;
acceleration(:, footwear, site, trial) = FirstDerivative(velocity(:, footwear, site, trial), 5000, 100, .0004);
_____________________________________________________________________________________________________
6 个评论
madhan ravi
2020-9-18
FirstDerivative function is missing.
Stephen23
2020-9-18
and we have no idea what it should be either. Ask your supervisor.
Alessandra Marcelo
2020-9-18
Star Strider
2020-9-18
I am not certain what the ‘FirstDerivative’ function does, and I get the impression it was not provided to you, either. However you can get an approximation with a numerical derivative with the gradient function. If the argument is a matrix, you will need to read the documentation in order to correctly interpret the results.
It assumes regularly-sampled data, however if they are not regularly-sampled, you can calculate the derivative as gradient(y)./gradient(x), assuming y is a function of x, and x are the sampling instants. Again, be mindful of the argument being a vector or a matrix.
Alessandra Marcelo
2020-9-18
Jon
2020-9-18
Using gradient(y)./gradient(x) is a great suggestion for dealing with non-uniform increments! I like the way it ensures the resulting derivative has the same length as the original y vector. I'll remember this, thank you
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!