what does this line of code mean,

조회 수: 2 (최근 30일)
fatima-zahra achbah
fatima-zahra achbah 2017년 9월 20일
댓글: fatima-zahra achbah 2017년 9월 20일
C{k} = xlsread(name)
the main program is this:
C = cell(1,9);
for k = 1:9
name = sprintf('%04i.csv',k);
C{k} = xlsread(name);
end
A = cat(3,C{:});
what I need is to have each file conserved as a matrix so that I will have access to it whenever I need it, in addition, i will be needing to have a histogram of each file

채택된 답변

Stephen23
Stephen23 2017년 9월 20일
편집: Stephen23 2017년 9월 20일
The line of code
C{k} = xlsread(name)
reads the file with filename name, and puts any numeric data into the k-th cell of cell array C. You can learn about cell arrays by reading the MATLAB documentation:
A cell array is just a container for holding some other data, and it does not matter what that other data is. In this case it holds the numeric array that is read from the file.
  댓글 수: 3
Stephen23
Stephen23 2017년 9월 20일
It is quite possible that they are not the same. It could easily be that the order of files is different to what you expect, or their location is not what you expect, or that xlsread is not importing that data as you expect it to. Your job is to learn how to debug code.
You should start to investigate by looking at the files, at their location: what folder are the files in? Find the name of the file that that you say is not imported correctly, and import it yourself into a variable: how does it look?
Have you read the xlsread documentation? Does it match with your data? Excel does do strange things with numeric data sometimes, especially when it thinks that they are dates, so you should check that too. It may be that xlsread is entirely the wrong tool to use, so you might like to investigate using another tool, such as csvread (as I wrote in my original answer).
fatima-zahra achbah
fatima-zahra achbah 2017년 9월 20일
Ah I see, ok I will try other tools, the csvread does not work with me there is always a problem with it; but since I know now the general structure it will be more simple. Thanks again for the information

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by