# how can I make a matrix into structure

2 views (last 30 days)
cheng chia jung on 15 Aug 2022
Commented: Rik on 15 Aug 2022
Hi everyone,I have a problem of change the matrix into the structure.
pic_pp=85;
cam_num=257;
pindex=zeros(pic_pp^2*cam_num,6);
pindex(:,1)=reshape(X1,pic_pp^2*cam_num,1);%x方向投影點
pindex(:,2)=reshape(Y1,pic_pp^2*cam_num,1);%Y方向投影點
pindex(:,3)=reshape(pic_depths,pic_pp^2*cam_num,1);%深度資訊
pindex(:,4)=reshape(OP_offsetX,pic_pp^2*cam_num,1);%X方向偏移量
pindex(:,5)=reshape(OP_offsetY,pic_pp^2*cam_num,1);%Y方向偏移量
pindex(:,6)=reshape(pic_strenth,pic_pp^2*cam_num,1);%強度資訊
pindex(pindex(:,3)==0,:)=[];%刪除為零資訊
i want to let the first line to be the first structure,and the second line to be the second one,third line to be the third one.
the third structure whitch included the fourth to sixth line of matrix,.How can i built the structure likes this?
T=struct.x(3).y(4).z(4)
ans=[2104 3 24
2315 3 146
1464 3 64
...
]
Rik on 15 Aug 2022
So you want a struct array? Why don't you make that then? It works the same as any other array.
I also don't understand what your last lines of code are meant to do.