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

3 次查看(过去 30 天)
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

采纳的回答

Sean de Wolski
Sean de Wolski 2011-5-11
  1 个评论
Sirius
Sirius 2011-5-11
Wh00t, strcat, that's what I've been searching for all this time, obviously :).
Thank you very, very much :).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by