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

Stephen23
Stephen23 2020년 11월 26일
편집: Stephen23 2020년 11월 26일
"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.
Thank you very much.
Look into "Grouping Variables"

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

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