Unrecognized function or variable 'FirstDerivative'
Mostra commenti meno recenti
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 Commenti
madhan ravi
il 18 Set 2020
FirstDerivative function is missing.
Stephen23
il 18 Set 2020
and we have no idea what it should be either. Ask your supervisor.
Alessandra Marcelo
il 18 Set 2020
Star Strider
il 18 Set 2020
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
il 18 Set 2020
Jon
il 18 Set 2020
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
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!