output to a variable name

1 view (last 30 days)
Leyon
Leyon on 31 Oct 2013
Commented: Leyon on 31 Oct 2013
outputFile is a 1x2 cell that contains 2 string names ('apple' and 'peach')
I want to assign those names to the output of a file:
outputFile(1) = importdata(char(filename(1)))
I get the following error:
Error using subsindex Function 'subsindex' is not defined for values of class 'cell'.
How can I get it to do what I need if it can do it? Any suggestions would help?

Accepted Answer

Matt J
Matt J on 31 Oct 2013
The proper way is to make the names dynamic fields of a struct, e.g.,
s.(outputFile{1})=....
I get the following error: Error using subsindex Function 'subsindex' is not defined for values of class 'cell'.
Don't think so. Not from the code you've shown. A full copy/paste of the error message text would reveal more, however.
  1 Comment
Leyon
Leyon on 31 Oct 2013
I saved the file and cleared my workspace and now it works. Thanks.

Sign in to comment.

More Answers (0)

Categories

Find more on Customize Object Indexing 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!