Effacer les filtres
Effacer les filtres

Max difference in a table column

2 vues (au cours des 30 derniers jours)
Elena
Elena le 5 Mar 2022
Modifié(e) : Elena le 5 Mar 2022
PLS HELP! Error!
I've got a table with about 20 numeric values seperated by different rows in one column. I would like to find the largest difference between each one (in order) and then select the largest difference.
so basically, how can I go through each row and subtract the previous row from it? and keep the largest value
EDIT: this is what i have and it works but...
myMax = -Inf
for i= 1:20
cNum = abs(t.Distance(i+1) - t.Distance(i))
if cNum > myMax
myMax = cNum
end
end
keep getting an error of:
Index exceeds the number of array elements (20).
Error in tabular/dotParenReference (line 114)
b = b(rowIndices);
Error in maxSegmentLength (line 20)
first = t.Distance(i+1)
not sure what to do!

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Mar 2022
cNum = max(diff(distanceCol));

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by