Question

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.

Was it helpful?

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)

OTHER TIPS

There are several ways of doing it.
Let v be the "projected vector" ( v = [6;15;24;] in your example ), and d be the desired number of columns ( d = 3 in your example ), then:

>> v * ones( 1, d ) / d

Alternatively

>> repmat( v/d, [1 d] )

In 2D:

B = sum(A')';

C = diag(B)*(ones(size(A))/size(A,2));

C =    
   2   2   2
   5   5   5
   8   8   8

It should be pretty straight forward to adapt to 3D.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top