Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I would like to import a matrix that has filenames in the first row with numbers and a letter. How can I do this wihout it importing as NaN? It's not a date format.

1 回表示 (過去 30 日間)
Michel Nieuwoudt
Michel Nieuwoudt 2016 年 9 月 16 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello,
I am trying to import a data matrix that has the first row as the Sample ID, which has numbers and a letter: e.g., 20W03091907521748421. When I import it, this gets converted to NaN. Is there some way I can import it into the matrix as the first row and keep its name please? The only other option I could find was date format.

回答 (1 件)

Star Strider
Star Strider 2016 年 9 月 16 日
You’re not saying how you’re importing it. If you’re using textscan, I would import it as a string. If you need to parse the numbers and letters, you can do that later with a regexp call:
str = '20W03091907521748421';
parsed = regexp(str, '\d+|([A-Z]?)', 'match')
parsed =
'20' 'W' '03091907521748421'
  2 件のコメント
Michel Nieuwoudt
Michel Nieuwoudt 2016 年 9 月 16 日
Thanks for the reply! I'm just importing using the Import tab, and selected a matrix of about 2000 columns and 1067 rows, and the first row has one of these names for each column. I can also use the load command. Is there maybe some way I can import or load the matrix, so that the first row is in a string format, for all 2000 columns?
Star Strider
Star Strider 2016 年 9 月 16 日
編集済み: Star Strider 2016 年 9 月 17 日
My pleasure.
I would use textscan. I generally do not use the import tab because textscan gives me more control over the way my file is imported.
EDIT (16 Sep 2016 at 01:30 UTC)
I can help you if you post your file or at least several rows of it. Writing textscan code is relatively straightforward, but I can’t do it without your file. Use the ‘paperclip’ icon to upload it to your original Question or to a Comment here.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by