I want get C
A=[13.89 32.56 23.09 22.02 32.06 20.81
28.16 29.97 29.12 29.83 9.21 24.21
18.60 26.93 7.07 18.87 16.16 21.38
17.00 31.00 23.00 24.17 12.21 25.32
9.49 17.09 15.81 8.00 13.45 26.00
43.0 35.17 16.16 39.00 10.05 18.87];
B=[2 5 6 1 5 3];
C=A(B(1),B(2))+A(B(2),B(3))+A(B(3),B(4))+A(B(4),B(5))+A(B(5),B(6))

 Akzeptierte Antwort

James Tursa
James Tursa am 14 Feb. 2018

0 Stimmen

C = sum(A(sub2ind(size(A),B(1:end-1),B(2:end))));

Weitere Antworten (0)

Kategorien

Mehr zu Statics and Dynamics finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by