Saving a value from matrix B, indexed by matrix A
이전 댓글 표시
Hello all, I have a pretty basic question which causes me problems. I have a 1x100 vector A. Each cell of this vector contains a different number, i.e. A(1,1) = 2010, A(1,2) = 3834, etc. Now, this values of a vector A are indeces, which index a column of vectors contained in all cells of a matrix B; matrix B is an 8x8 cell matrix, and each of its cells contain a 1x4000 vector of numbers. Could you tell me what is your idea of finding values indexed by the vector A in all of the cells of matrix B?
Update from below: all the numbers in 'indeces' vector are supposed to be found in each cell of the 8x8 matrix 'cell', i.e. I expect the output from each cell of the output matrix (the 'What you want' one) to be a vector of 1x132, providing the sample files I attached. Here it seems like I overwrite and save just the 132th value, since the output is just an 8x8 matrix of numbers, instead of 8x8 cell matrix of 1x132 vectors.
댓글 수: 2
James Tursa
2018년 6월 8일
Please provide a short example of inputs and desired output(s) so we are clear what you want.
sprklspring
2018년 6월 8일
채택된 답변
추가 답변 (1개)
sprklspring
2018년 6월 11일
0 개 추천
댓글 수: 4
Majid Farzaneh
2018년 6월 11일
Hi again. So you need another cell matrix.
I hope this helps:
load cells
load indeces
for i=1:numel(cells)
result{i}=cells{i}(indeces);
end
After this, you have 1-by-64 result cell matrix which every cell has 132 values.
Majid Farzaneh
2018년 6월 11일
편집: Majid Farzaneh
2018년 6월 11일
If you want result to be 8-by-8 you can use 2 loops:
load cells
load indeces
for i=1:8
for j=1:8
result{i,j}=cells{i,j}(indeces);
end
end
sprklspring
2018년 6월 12일
Majid Farzaneh
2018년 6월 12일
You're welcome
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!