How to open .csv files?

How do I loop through csv files in Matlab?

  • I wrote a code to do something for a csv file full of data. The problem is that I need to do the same thing for 49 different files. My advisor told me I can loop through all 49 csv files and not have to copy and paste the code 49 times. I tried to loop through the files but I can't figure it out. Here is the code that I wrote so far: for f=[1:length(filenames)]; %filenames is the array with all the filenames f=0; f=f+1; y=csvread(filenames(f),2) I keep getting an error message saying that the filename must be a string. In the filenames array, I did address it as being a string. I don't get this. Any help is greatly appreciated.

  • Answer:

    Change numbers to strings with function num2str. Try this concept: for ix = 1 : 3 filename = ['name' num2str(ix)] end

Annonymo... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.