0

I am currently working in matlab to design a way to reconstruct 3D data. For this I have two pictures with black points. The difference in the amount of points per frame is key for the reconstruction, but MATLAB gives an error when matrixes are not equal. This is happening becaus the code is not doing what I want it to do, so can anyone hel me with the following?

I have two columns of Xdata: XLI and XRI

What matlab does when I do XLI-XRI is substracting the pairs i.e XLI(1)-XRI(1) etc, but I want to substract each value of XRI of every value of XLI. i.e

XLI(1)-XRI(1,2,3,4 etc)
XLI(2)-XRI(1 2 3 4 etc)

and so on

Can anyone help?

Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122

2 Answers2

2

I think you are looking for a way to deduct all combinations from eachother. Here is an example of how you can do that with bsxfun:

 xLI = [1 2 3]
 xRI = [1 2]
 bsxfun(@minus,xLI ,xRI')
Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122
0

I cannot comment on Dennis's post (not enough points on this website) : his solution should work, but depending on your version of Matlab you might get a "Error using ==> bsxfun" and need to transpose either xLI or xRI for that to work :

bsxfun(@minus,xLI' ,xRI)

Best,

Tepp

sg1234
  • 600
  • 4
  • 19