I am trying to add a column called "Lifespan" into the dataset in my workspace entitled "options_20020208".
I need to do this multiple times via a loop (Since there are multiple tables)
My problem is that I need to insert "Name" and have matlab process it as "options_20020208":
Name = options_20020208
Start = cellstr(Name(:,5))
End = cellstr(Name(:,3))
Start = datenum(Start)
End = datenum(End)
Lifespan = wrkdydif(Start,End)
Name.Lifespan = nominal(Lifespan)
I need to make it such that matlab reads the above code is read as :
Start = cellstr(options_20020208(:,5))
End = cellstr(options_20020208(:,3))
Start = datenum(Start)
End = datenum(End)
Lifespan = wrkdydif(Start,End)
options_20020208.Lifespan = nominal(Lifespan)
This is a fairly basic question, I know.. but I'm a newbie and not really sure how to approach it.
Any advice would help!!
Name_string = 'options_20020208';
eval([Name_string,'.Lifespan = nominal(Lifespan);']);
For a better answer, please show the exact line defining Name in your actual code.