Newbie needing to create matrix elements dependent on other elements

Hi
I have a matrix of many rows and 6 columns
A1 A2 A3 A4 A5 A6
B1 B2 B3 B4 B5 B5
etc
I want to create a new column 7 that will contain
A7 = sqrt(A1^2+A2^2+A3^2)
B7 =sqrt(B1^2+B2^2+B3^2)
etc.
How would I do this please?
thanks

 채택된 답변

James Tursa
James Tursa 2016년 11월 8일
편집: James Tursa 2016년 11월 8일
A = your Nx6 matrix
A(:,7) = sqrt(sum(A(:,1:3).*A(:,1:3),2)); % The RSS of the 1st 3 columns by row

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Aerospace Blockset에 대해 자세히 알아보기

질문:

2016년 11월 8일

댓글:

2016년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by