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.
Look into "Grouping Variables"

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

提问:

2020-11-26

评论:

dpb
2020-11-26

Community Treasure Hunt

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

Start Hunting!

Translated by