Calling a function using a string generated earlier in code.
1 view (last 30 days)
What I want to do is call a function using a string that was generated earlier in the code. The initial function takes user input to create the string for the internal function. Here is what I have so far:
LastPullTable = [Cmdty2Pull '_History'];
I want to then do the following
irow = length(LastPullTable(:,1)
where irow is set to length of cell array CL_History if the user inputs CL.
Is there an easy way to do this that I just dont know about?
Jonathan on 26 Jul 2012
Here is a solution that will work depending on how many different cells you're talking about.
Define the cell (in any function) like this:
and call it like this:
irow = length(getappdata(0,LastPullTable));
The problem is (how I see it) that you have to be using some sort function to reference a string or else "length" will just give you the length of the string.
This solution will work, but it may not be efficient or reasonable depending on what kind of data you're dealing with and the amount present.