how can I make a matrix from each row of an excel sheet data and save each matrix in to a folder

조회 수: 2 (최근 30일)
Iam working with a spreadsheet data that is being imported to matlab using xlsread function. Is there any way to access each row from that excelsheet and make each row a seperate matrix and store them in a seperate structure or an array to use it later? And after storing each matrix in to that structure ,how can I access some of the matrices later

채택된 답변

Jan
Jan 2018년 1월 31일
data = xlsread(FileName);
Now data contains the numerical values of all columns. Now you want to save them as matrices in different folders. It is not clear, what this exactly means, but perhaps this helps:
for k = 1:size(data, 2)
folder = fullfile('D:\Data\', sprintf('Folder%03d', k));
Column = data(:, k);
save(fullfile(folder, 'column.mat'), 'Column');
end
Now each folder contains the file Column.mat, in which one column of the Excel file is saved. This does not sound efficient, because it duplicates the data. But maybe there is a good reason to do so.
  댓글 수: 3
Jan
Jan 2018년 2월 1일
@sruthy: Okay. How can we help you? Do you know how to pad the vectors to be square matrices? In which format do you want to save these matrices? Which rows do you want to store in which kind of array?
sruthy shankar
sruthy shankar 2018년 2월 1일
sir,I have used the following code to make each row a square matrix. data_M = xlsread('Book1' ); M_matrix=[]; for k = 1:size(data_M, 1 ) row_M = data_M(k, : ); padding = zeros(1,6); vec_M=[row_M,padding]; rowMatrix_M = vec2mat(vec_M,6); M_matrix=[M_matrix rowMatrix_M]; end here M_matrix is that array,but I have to split that array in to two,each containing equal number of matrices so that i can give it for training as well as testing, how can it be done ? or instead of this array is there exist some other method to store that matrices and later access them

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by