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

7 ビュー (過去 30 日間)
Sirius
Sirius 2011 年 5 月 11 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by