How to convert one large vector into an array of matrix?

조회 수: 1 (최근 30일)
Nitinkumar Ambekar
Nitinkumar Ambekar 2016년 9월 18일
댓글: Nitinkumar Ambekar 2016년 9월 18일
I have a result column vector `yfit` containing result for multiple images one after another, for example, for images of size 512x512 the `yfit` would contain 1 to 262144 for first image, which further can be reshape() to get 512x512 result matrix. Further, 262145 to 524289 for second image's result matrix, and so on.
How to convert `yfit` in an array of matrix? Where each matrix would be a result of an image. Such as,
x[1] => matrix of first image (512x512)
x[2] => matrix of second image (512x512)
I am not sure, but it would be like
x[1] = reshape(yfit(1:262144), 512,512);
x[1] = reshape(yfit(262144:524289), 512,512);
What I want is `X` having result of all images. Thanks!!

채택된 답변

Mischa Kim
Mischa Kim 2016년 9월 18일
편집: Mischa Kim 2016년 9월 18일
Nitinkumar,
yfit = 1:5*5*10; % just as an exmple: 10 5x5 images
x = reshape(yfit,[5,5,10]);
You basically convert into a 3D array. The first image is accessed through
x(:,:,1)
  댓글 수: 1
Nitinkumar Ambekar
Nitinkumar Ambekar 2016년 9월 18일
This worked! But I thought I could plot this X variable, but failed. How can I show this X variable as 3D view?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by