Matrix indexing, getting back my original matrix.
이전 댓글 표시
Hi,
I have a matrix
mat= [ 1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9; ...
1 2 3 4 5 6 7 8 9];
and I sub-sample it using the simple command
newMat= mat(1:4:end, 1:4:end);
Is there a way later on to get back the indexes I lost from the original matrix, if I want to reconstruct it in a new matrix likewise
newMat2= zeros(size(mat, 1), size(mat, 2));
newMat2(1:4:end, 1:4:end) = newMat;
So what I want is to replace the columns and rows I lost with lets say NaN.
댓글 수: 1
Jan
2014년 6월 14일
I do not get the problem. In your example you fill the missing values with zeros. So all you want to do is using nan() instead of zeros()?
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2014년 6월 14일
You haven't lost anything
mat=repmat(1:9,6,1) % Example
new_mat=mat(1:4,1:4)
You have both the original matrix and the new one, maybe you can give more details about loosing indices
카테고리
도움말 센터 및 File Exchange에서 Monte Carlo Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!