Turning a lot of variables into a string

3 ビュー (過去 30 日間)
Steve
Steve 2013 年 5 月 17 日
I have a list of some 500+ variable names in Excel. What I want to do is to turn them all into strings so I can use them in Matlab. Is there a way I can import the names in as a string without having to add ' ' around each entry?
  3 件のコメント
Matt Kindig
Matt Kindig 2013 年 5 月 17 日
編集済み: Matt Kindig 2013 年 5 月 17 日
Are you importing them using xlsread()? If so, the '' should not be necessary.
If you are just copy-pasting the names into Matlab, why not add a formula (in Excel) concatenating the '' to the variable name, using the CONCATENATE() function in Excel?
David Barry
David Barry 2013 年 5 月 17 日
If you don't want to import automatically then you can just create an empty cell array and paste the excel data straight in.
data = cell(0); % Create empty cell array

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2013 年 5 月 17 日
[numbers, variableNameStrings, raw] = xlsread(fullFileName);
variableNameStrings should be a cell array with all your strings in it. See the FAQ for an explanation of cell arrays: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by