use function many times with different folders as input

1 回表示 (過去 30 日間)
Jeane
Jeane 2014 年 4 月 28 日
コメント済み: Jeane 2014 年 4 月 28 日
I have a function where you can give a folder as input. This function works perfectly.
I have to use this function many times with different folders as input. I made something like this, but it does not work:
dir1={C:\folder\subfolder1\subfolder2\subfolder3\A\01',C:\folder\subfolder1\subfolder2\subfolder3\B\01};
for i=1:length(dir1)
dir1=dir1{i};
[theta,omega]=program(dir1); % The program which works outside of the list
end
it gives the error:
Cell contents reference from a non-cell array object.
Error in run (line 19)”
Line 19 is the dir1=dir{i}. I assume this is the error because dir1 is a folder with data, and not one datapoint? How can I use the program [theta,omega]=program(dir1,dir2) for different folders?

採用された回答

Image Analyst
Image Analyst 2014 年 4 月 28 日
Don't do this:
dir1=dir1{i};
[theta,omega]=program(dir1);
You just blew away dir1 by replacing it with only one of the items in the list. Do this:
[theta,omega]=program(dir1{i});
  1 件のコメント
Jeane
Jeane 2014 年 4 月 28 日
Thank you for your explanation! It works now!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 4 月 28 日
Your Dir1 is missing an apostrophe (')
You have not given a value to dir1, only to Dir1
  2 件のコメント
Jeane
Jeane 2014 年 4 月 28 日
I am sorry, I did not copy the code but wrote it again in word and made a few mistakes! I changed it!
Image Analyst
Image Analyst 2014 年 4 月 28 日
You were missing 3 apostrophes. You had both forward and backward tilting ones, plus one normal one. Use only straight, vertical apostrophes. After that, are you still having a problem? If not, mark the answer as accepted to close it out.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by