MATLAB Answers

Read several large csv and store as separate variables

조회 수: 18(최근 30일)
Louise Wilson
Louise Wilson 18 Nov 2019
댓글: Rik 19 Nov 2019
I have 26 large .csv files that each take a while to load in to Matlab. I would like to be able to read them all in, using one for loop, so that I can leave the loop to run and work on something else while all of the files import. I would like each to be stored as a separate variable.
I have tried this, but the code fails on the last line where I try to read in the .csv using readmatrix() and store it with a name depending on the file that the loop is currently processing. In this example, I choose to start at the 17th .csv file in the folder as I have inspected the first 16 in a past life :-) The .csv files are 7GB otherwise I would attach an example.
directory=('Y:\SoundTrap\PSD Output');
d=dir(fullfile(directory, '*.csv')); %list all .wav files in path folder
for i=17:files
disp(d(i).name); %display filename
filename=fullfile(directory, d(i).name);
There error I get is:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in checkPSDoutput (line 14)
Thanks for your help!
  댓글 수: 3
Rik 19 Nov 2019
That was indeed was I meant. Can you still call it a typo if you're using the wrong word?

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

채택된 답변

Star Strider
Star Strider 18 Nov 2019
Perhaps saving it in a cell array would work:
Note the curly brackets {} denoting cell-array indexing.
See Access Data in Cell Array to help you work with the data later if you are not familiar with cell arrays.
Experiment to get the result you want.

추가 답변(0개)




Community Treasure Hunt

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

Start Hunting!

Translated by