Search code examples
matlabvectortransformprojectionexpansion

Matlab vector expansion


I have a 1-D vector and need to "unproject"(sorry, I dont know how to tell it) it to 3D-space. If there is a built-in function to avoid loops?

A 2D example to clarify. I had

[1 2 3;
 4 5 6;
 7 8 9]

It has been projected to the first dimension. Gotten:

[6;
15;
24]

Now I need to "de-project" it and get:

[2 2 2;
 5 5 5;
 8 8 8] 

Then I will repeat it for a set of angles.

This is like a Radon transform but in 3D. So do we have a function for such kind of action in 3D-space and (if I am lucky) for arbitrary angles of the axis of interest. Thank you.


Solution

  • Here is an easy way to do it in 3D for this vector:

    v = [6;15;24];
    
    repmat(v, [1 3 3])/9
    

    A generalized solution that will unproject any vector into a shape with your requiredDimensions:

    v = [6;15;24];
    requiredDimensions = 3;
    
    n = numel(v);
    myDims = [1 repmat(n,1,requiredDimensions - 1)];
    repmat(v, myDims )/prod(myDims)