フィルターのクリア

Info

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

How to allocate files to an array?

1 回表示 (過去 30 日間)
Parthiban C
Parthiban C 2017 年 12 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a folder with 40 results files. I need to to define like this. A1= Resultsfile1, B1= Resultsfile2 so on..The first results file in that folder should be allocated to A1 second one should be allocated to B1, 27th one to be allocated to AA1 and so on... Someone hep me with this?
  1 件のコメント
Stephen23
Stephen23 2017 年 12 月 19 日
編集済み: Stephen23 2017 年 12 月 19 日
You should first read this:
And then use indexing with just one array (which could be numeric, cell, or struct).

回答 (1 件)

Rik
Rik 2017 年 12 月 19 日
編集済み: Rik 2017 年 12 月 19 日
Don't. Automatically generating names for variables (e.g. with eval) is a bad idea. Use cell arrays instead.
Introspective programing (eval and other functions like it) is slow, and the MATLAB documentation warns specifically against it. Using eval is slow, makes debugging difficult, and removes all code helper tools (code checking, syntax hints, code completion, variable highlighting, etc.). A longer discussion can be found here. If you are not an expert and you think you need eval, there are probably better solutions to your problem. Also, if you are not an expert, you might find interesting and helpful hints on this page (and if you are an expert, you can still learn from it).
Edit: Of course I meant variable names, generating filenames is of course not necessarily wrong.

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

Community Treasure Hunt

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

Start Hunting!

Translated by