output to a variable name

조회 수: 2 (최근 30일)
Leyon
Leyon 2013년 10월 31일
댓글: Leyon 2013년 10월 31일
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?

채택된 답변

Matt J
Matt J 2013년 10월 31일
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
Leyon
Leyon 2013년 10월 31일
I saved the file and cleared my workspace and now it works. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by