what does this line of code mean,
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
fatima-zahra achbah
am 20 Sep. 2017
Kommentiert: fatima-zahra achbah
am 20 Sep. 2017
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
1 Kommentar
Akzeptierte Antwort
Stephen23
am 20 Sep. 2017
Bearbeitet: Stephen23
am 20 Sep. 2017
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 Kommentare
Stephen23
am 20 Sep. 2017
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).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!