how to plot matrix
조회 수: 133 (최근 30일)
이전 댓글 표시
Hi all,
I have 2304x1024 matrix. I assume that each 3 rows of this matrix describe an image.(so I have 768 images and each image size = 3x1024 ). And want to plot it.
Can anyone help me with this please?
댓글 수: 0
답변 (2개)
Subhadeep Koley
2020년 12월 24일
This code snippet extracts out the first image and plots it. Similarly you can extract the other images.
% Defining a random matrix for demo
matrix = rand(2304, 1024); % Use your matrix here
% Extract first 3 rows
image1 = matrix(1:3, :);
% Visualize
figure
imagesc(image1)
댓글 수: 3
Subhadeep Koley
2020년 12월 28일
% Defining a random matrix for demo
yourMatrix = rand(2304, 1024); % Use your matrix here
% Extract all images in a cell array
imagesArray = cell(768, 1);
ind = 1;
for idx = 1:3:2304
imagesArray{ind, 1} = yourMatrix(idx:idx+2, :);
ind = ind + 1;
end
% Visualize them all in one figure
figure
montage(imagesArray, 'BorderSize', 20)
colormap parula
Durganshu
2020년 12월 24일
편집: Durganshu
2020년 12월 24일
Let your 2304x1024 matrix be data. I'm assuming that you have to obtain these images successively in a single plot. If that is not the case, please specify how do you actually want to plot it.
for i=1:3:size(data,1)
for j=1:size(data, 2)
image(1,j) = data(i,j);
image(2,j) = data(i+1,j);
image(3,j) =data(i+2,j);
end
imagesc(image);
hold on;
end
Hope that helps!
댓글 수: 5
Durganshu
2021년 1월 3일
Hi Fatma,
Sorry for the late reply. I hope this can resolve your issue.
figure
position =1;
for ind=1:768
start= (ind-1)*3+1;
stop=ind*3;
data = wholedata(start:stop,:);
subplot(1,768,position);
imagesc(data);
hold on;
position = position+1;
end
Further, you can even use imshow and subplot for your functionality. I have never used it personally, so I'll just share the link where you can find more information on its impementation. Link!
Hope that helps!
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!