Does one rename variable names after reading data? Part 2
Mostrar comentarios más antiguos
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 comentarios
"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
el 26 de Nov. de 2020
dpb
el 26 de Nov. de 2020
Look into "Grouping Variables"
Respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!