How to calculate the delta

8 ビュー (過去 30 日間)
Mekala balaji
Mekala balaji 2016 年 8 月 13 日
回答済み: Azzi Abdelmalek 2016 年 8 月 13 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 13 日
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 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by