I have variable input names that I would like to assign to titles of graphs. E.g 'UKtreasury_returns', 'China_logReturns', 'US_ret' ....
I want to extract simply up until the underscore in each example. They are function arguments, so i have tried:
header = inputname(1);
subject = header(1:'_'-1);
finalTitle = [subject, ' - first three PCs'];
the '-1' is there because I do not want the underscore included in the output.
This didn't work, and I get the rror message: 'index exceeds matrix dimensions'.
How can I dynamically reference the underscores? Any tips how a solution might be extended for other indexing problems I might face in the future?
subject = textscan(s,'%s %*[^_]','delimiter','_')