How do I implement this for loop calculation in direct matrix or vector calculation?

I have a matrix A of order (n+1)*3. And I have to perform a calculation. for loop implementtaion of it is given below.
R=0.0;
for j=1:1:n
R=R+(A(j+1,1)-A(j,1))^2+(A(j+1,2)-A(j,2))^2+(A(j+1,3)-A(j,3))^2;
end
How do I implement above calculation using matrix or vector notation. I need this for making optimization code run faster.
Thank you.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2021년 10월 2일

댓글:

2021년 10월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by