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!