Effacer les filtres
Effacer les filtres

Scaling 4D vector to specific bounds

3 vues (au cours des 30 derniers jours)
Piotr Pawlowski
Piotr Pawlowski le 8 Août 2019
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

Réponses (1)

Akhil Gopinath
Akhil Gopinath le 16 Jan 2020
Modifié(e) : Akhil Gopinath le 16 Jan 2020
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.

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by