Clear Filters
Clear Filters

Changing a string variable on each iteration of a for loop for saving

3 views (last 30 days)
There’s a problem I’ve been having as long as I’ve been using matlab, and I’d like to get an answer once and for all. It has to do with input that has to be in quotes, saving, and changing filenames in a non-manual manner. Let me illustrate. I mainly use MatLab in my function as neuroscientist in training. I program my experiments in it, and collect the matrices with the results of my experiment, to be saved as .mat files, and .csv files, and exported to data analysis programs. In this line of work, at some point you want to split your results to have a separate matrix for each participants responses to each condition. Right this moment, I have done 7 participants, and 8 conditions, that makes 56 separate matrices. I do NOT want to save them all by hand. So I’ve been looking for a way to use for loops to do that for me. However, to save a matrix, use the save function, or the csvwrite function, the filename needs to be supplied within quotes => ‘’. The eval function, which I use to change the name of the matrix while filtering the data, is thus not useable, since quotes within quotes don’t work. I’ve had this problem also with other functions that need string inputs. Is there ANY way, in MatLab, to “isolate quotes”? Such as put them between other signs? Some programming languages use / for that, so that /’/ makes the ‘ read within the quotes it’s already in. Or maybe some other smart way to vary string variables in a for loop in such a way that I can input them into save or csv write functions? Thanks a bunch! Sirius

Accepted Answer

Sean de Wolski
Sean de Wolski on 11 May 2011
  1 Comment
Sirius
Sirius on 11 May 2011
Wh00t, strcat, that's what I've been searching for all this time, obviously :).
Thank you very, very much :).

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!