How to import a specific column from a matrix that is looping through a directory?
5 次查看(过去 30 天)
显示 更早的评论
So I am trying to bring in a set of excel spreadsheets in a loop which I have successfully done so i have a directory, but now i want to read column 5 of each spreadsheet as it loops round so I finish with all 41 columns of data saved into a single matrix. This is my script so far:
gAfiles=dir('*'); %create directory
%%creating loop
for i=9:50
filename=gAfiles(i,1);
z_force=readmatrix(filename);
0 个评论
回答(1 个)
Cris LaPierre
2020-12-28
Use indexing to tell MATLAB where to store the results. You can find an example in the for loop documentation.
When importing the data with readmatrix, specify the "Range" name vaue pair so it reads the 5th column. You can see syntax and examples under Name-Value pair arguents in the readmatrix documentation page.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!