필터 지우기
필터 지우기

Scaling 4D vector to specific bounds

조회 수: 3 (최근 30일)
Piotr Pawlowski
Piotr Pawlowski 2019년 8월 8일
편집: Akhil Gopinath 2020년 1월 16일
Hi everyone.
I have a rather uncommon problem. I'm trying to fit a vector (4D vector to be precise) to specific bounds, which I determined, but with preservation of direction. Let me explain:
e.g.
  1. generate 10 vectors, from range [0 5] for 1st coordinate, [0 9] 2nd, [0 4] third, [0 8] 4th. All coordinates are known
  2. scale vectors that have coordinates outside their bounds
  3. leave good vectors untouched
I was trying to figure it out on 2D plane. One conclusion is that I cannot just force outgoing coordinates to their maximum boundary values - it won't preserve direction. Such a method pinns those vecotrs all to the corner of a "boundary rectangle". I could figure out some conditional rules, but it is not what im trying to accomplish. My goal is to find a procedure, such that I can quickly apply to matrix of generated vectors. And since problem is 4D it is even harder to manage a solution. Any suggestions? Maybe dealing with norms?
Thanks in advance

답변 (1개)

Akhil Gopinath
Akhil Gopinath 2020년 1월 16일
편집: Akhil Gopinath 2020년 1월 16일
Hi Piotr
you are thinking in the right direction by thinking of norm.
Maybe you can try to find the norm of the vector and transform them into unit vectors by diving with the calculated norm.
This will preserve the direction of the vectors.
You can then multiply with a scalar to resize the vector to the giving bound or add a scalar to shift the position but retaining the direction of the vectors.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by