필터 지우기
필터 지우기

how to divide a matrix by its norm in for loop

조회 수: 1 (최근 30일)
Sunil Ojwani
Sunil Ojwani 2019년 10월 25일
댓글: Sunil Ojwani 2019년 10월 25일
i want s/|s|
s=[x(2)+x(1);x(1)+x(3)];
i write as it
for i=1:n
s1(i)=x2(i)+x1(i);
s2(i)=x1(i)+x3(i);
sm(:,i)=[s1(i);s2(i)];
if ( x(i)~=0 )
u1(i)=s2(i)/norm(sm(:,i));
u2(i)=-0.1*s1(i)/norm(sm(:,i));
end
end
pleae help me

답변 (1개)

Steven Lord
Steven Lord 2019년 10월 25일
There's no need for a for loop here. Just use the norm function and divide. If you were trying to divide each row or each column of the matrix by its vector norm instead of dividing the whole matrix by its matrix norm, use the vecnorm function instead.
  댓글 수: 1
Sunil Ojwani
Sunil Ojwani 2019년 10월 25일
but i want plot it so i am using for loop and x1 x2 x3 are state that i obtain from ode45

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by