How to calculate the delta
8 views (last 30 days)
Show older comments
Mekala balaji
on 13 Aug 2016
Answered: Azzi Abdelmalek
on 13 Aug 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 Comments
Accepted Answer
Azzi Abdelmalek
on 13 Aug 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 Comments
More Answers (0)
See Also
Categories
Find more on Gaussian Process Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!