How to name by checking the entrys of a table?
3 views (last 30 days)
Show older comments
Hi Guys, i I'm new in matlab so i need a little help to get started.
What i'm doning is to use the fullfact Method to create a table. There are 5 columns then and 216 rows. The number of factors depends - let me show you:
diameter=[ 10 15]; % diameter in mm
density=[ 0 50 100]; % density in percent
orientation=[ 0, 45, 90]; % orientaion in degree
seam=[0,1]; % 0 align, 1 random (can be adjusted to strings if really wanted)
layheight=[ 0.2 0.3 0.4]; % layheigth in mm
contournumbers=[1 2]; % numbers of contours
What i want to do is to get a logic naming of the single parts.
% Density: FG1, FG2
% Orientation: O0 O45 O90
% Seam: SO, SC
% Diamater: D15, D20
% Layheight: LL, LM, LH
% contournumbers: C1, C2
So a example of the part with all factor to be on 1 would be: FG1_O0_SO_D15_LL_C1
How can i like get a new table where matlab checks the entry of the columns in each row and depending on the entry get me out a new table with the naming?
Would be logic to get with "for" through all of the datas, but actually i can not figure out how to get me a string with a internal if function.
hope you guys can help me!
Thanks in advance!
2 Comments
Jan
on 16 Nov 2018
I do not understand the question. "use the fullfact Method to create a table" is not clear. fullfact replies a matrix, doesn't it? Then how is the table created? "get a logic naming of the single parts" - what are "parts"?
Stephen23
on 16 Nov 2018
Edited: Stephen23
on 16 Nov 2018
"So a example of the part with all factor to be on 1 would be: FG1_O0_SO_D15_LL_C1"
"hope you guys can help me!"
The best help you will get is advice to avoid what you are trying to do:
"How can i like get a new table where matlab checks the entry of the columns in each row and depending on the entry get me out a new table with the naming?"
Ugh. Forcing meta-data into variable names is one way that some beginners force themselves into writing pointlessly slow, complex, buggy code that is hard to debug. Read this to know why:
Accepted Answer
Jan
on 16 Nov 2018
"FG1_O0_SO_D15_LL_C1" seems to be an extremely ugly name for a variable or name of a table column. Here you hide important information in the name in a very cryptic fashion. It sounds like you want to create these variables dynamically, which is a very bad idea - see TUTORIAL: Eval .
Prefer to store the data in a clear way. E.g. a struct with the fields 'Density', 'Orientation', ... is much better than a magically encrypted keyword like 'FG1_O0_SO_D15_LL_C1'.
I'm not sure what "get me out a new table with the naming" means, but this condensed name is not useful as header or a table also, because it is confusing for a human reader and unnecessarily compact for the computer.
0 Comments
More Answers (1)
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!