- table indexing using curly braces, e.g. PhyProp{'a'}
- structure instead of table
- nested functions instead of bundling/unbundling.
Alternative for readable but slow Table dot notation
6 次查看(过去 30 天)
显示 更早的评论
Hi really like how legible the dot notation is for tables in Matlab... however it is just soooo slow to access and slows all my routines down.
I was wondering if there was an alternative to this?
Basically I was bundling up sets of data such as PhyProp, NumProp, GeomProp into tables and passing those to sub-functions.
At the top of each function I would unbundle the variables I needed:
say:
a = PhyProp.a
b = PhyProp.b
c = GeomProp.c
etc...
It made the function argument lists much more conscise and the code overall was still readable as all the unbundling always happened at the top of the function.
What I would like to avoid is to have to use indices, as it means you have to remember what they are before you can write new code.
for example if I had a cell array or something I could do something similar:
a = PhyProp{1}
b = PhyProp{2}
etc... but I have to remember that a is at index 1 etc...with tables it was just so much more readable.
I'll take any advice :)
5 个评论
Stephen23
2022-5-30
编辑:Stephen23
2022-5-30
"Why create local copies of the same data? Just use the table variables as is."
As long as the variables are not written to, then probably no local copies are made:
A local variable is just a handle to the existing data, without the repeating the indexing operation.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!