How to create matrix from multiple vectors?

조회 수: 246 (최근 30일)
PaulLe
PaulLe 2019년 6월 30일
편집: PaulLe 2019년 7월 14일
Hi everyone,
I read a database image, it includes many images. I describe each image with a vector have to size is 8400 x 1. Thus, I have multiple vectors.
Now, I want to arrange them for one matrix.
Please help me. Thank you so much.
clc;
clear all;
srcFile = dir('C:\images\*.jpg');
for i = 1:length(srcFile)
filename=strcat('C:\images\',srcFile(i).name);
img=imread(filename); % read 1258 images
img1 = img(:); % image to vector
%%How to arrange 1258 vectors (img1) become matrix?
end

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 6월 30일
Matrix is also vector, you can concatenate them as new matrix
result=[vec1;vecc2;vecc2....]
Result size: Number of vector concatenated*8400x1
or
result=[vec1,vecc2,vecc2,....]
How you concatenate depends of required size of result matrix
Result size: 8400x1*Number of vector concatenated
  댓글 수: 2
PaulLe
PaulLe 2019년 6월 30일
Dear KALYAN,
Thank you for your support.
Howewer, Number of vectors are 1258. I can't use your suggest command.
Le.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 6월 30일
편집: KALYAN ACHARJYA 2019년 6월 30일
I just provided, how the thinks works. You can use concatenate arrays within a loop,check here

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by