How to get norm (magnitude) of a vector the simple way?

조회 수: 4 (최근 30일)
Niklas Kurz
Niklas Kurz 2021년 5월 4일
편집: Niklas Kurz 2021년 5월 8일
I just want to get the norm of
syms phi the;
c = [-cos(phi)*sin(the)^2;-sin(phi)*sin(the)^2; - cos(the)*sin(the)*cos(phi)^2 - cos(the)*sin(the)*sin(phi)^2]
norm(c,2)
isn't really simplifying anything
If I type it manually:
simplify(sqrt(cos(phi)^2*sin(the)^4+sin(phi)^2*sin(the)^4+sin(the)^2*cos(the)^2))
I get a simple answere:
(sin(the)^2)^(1/2)
  댓글 수: 5
David Goodmanson
David Goodmanson 2021년 5월 6일
Hi Niklas,
If your last two vector elements were
- cos(the)*sin(the)*cos(phi) - cos(the)*sin(the)*sin(phi)
i.e. cos(phi) and sin(phi) not squared, then you would get what you say. But since cos(phi) and sin(phi) are squared, you don't.
Niklas Kurz
Niklas Kurz 2021년 5월 8일
I'm sorry for forgetting the simicolons in c. It might have been hard for you to reproduce what I was trying to create.

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

채택된 답변

Nagasai Bharat
Nagasai Bharat 2021년 5월 7일
Hi,
From the documentation of norm and simplify you could find the usage of both these functions. norm would be used to calculate the norm of a vector/matrix but not for an expression. simpify would be used in the simplification of an algebric expression.
  댓글 수: 1
Niklas Kurz
Niklas Kurz 2021년 5월 8일
편집: Niklas Kurz 2021년 5월 8일
well, it actually works if u were to incorporate some assumptions:
assume(phi>0);assume(the>0); assume(phi,'real'); assume(the,'real')
then, under these conditions
simplify(norm(c))
will simplify a lot (actually >0 not necessary)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by