How to calculate the delta
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mekala balaji
le 13 Août 2016
Réponse apportée : Azzi Abdelmalek
le 13 Août 2016
Hi,
I have below matrix:
1 3 Signal 6 1 Offset 3
3 5 Deffect 4 0 Offset 6
1 3 Signal 6 1 Offset 3
3 5 Signal 4 0 Offset 6
I want to calculate the delta of the rows ( I struck how to avoid if it is not a double value): My desired output as below:
2 2 Deffect -2 -1 Offset 3
-2 -2 Signal 2 1 Offset -3
2 2 Signal -2 -1 Offset 3
But the text column index may vary in my future input(may not be in column 3 & 6, and the text may appear in many columns)
Many thanks in advance
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 13 Août 2016
M={1 3 'Signal' 6 1 'Offset' 3
3 5 'Deffect' 4 0 'Offset' 6
1 3 'Signal' 6 1 'Offset' 3
3 5 'Signal' 4 0 'Offset' 6}
idx=all(cellfun(@isnumeric,M))
A=M(2:end,:);
A(:,idx)=num2cell(diff(cell2mat(M(:,idx))))
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Database Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!