Does one rename variable names after reading data? Part 2
古いコメントを表示
In a previous post. I learned that
"It might appear "cumbersome" to type "T." again and again, but in the long run, you will realize that this is much more flexible and efficient coding approach. Also, MATLAB supports several operations on tables which make thing easy. That will not be possible if you create separate variables."
Now suppose I would like to do subsetting operations like
These operations seem to require definining new variables separately? Is it correct?
3 件のコメント
"These operations seem to require definining new variables separately? Is it correct?"
No. It is very very rare that coding in any language "requires" one specific approach to a task, in most cases you have many approaches for solving a particular task. Understanding which approach/es will be simpler, more efficient, easier to maintain, etc. comes with practice and experience and reading the documentation and continuous learning. In general, following the good practices for that particular language will go a long way to helping you down that path.
There is nothing in your example link that "requires" separate variables, and that would be a very inefficient approach for a larger number of variables (both in terms of runtime and writing/maintaining time), basic indexing would be a much simpler and more effiicient approach.
A common mistake that some beginners make with MATLAB is wanting to split data up into lots and lots of variables, but this makes accessing and processing data more difficult and much less efficient.
alpedhuez
2020 年 11 月 26 日
dpb
2020 年 11 月 26 日
Look into "Grouping Variables"
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!