Too many input arguments with parfor loop

trying to run this instruction
>> Iteration('Al',[100:25:175],1.33)
function Iteration(type,data,n)
tic
length1 = length(data);
switch type
case 'Al'
parfor i = 1:length1 % line:21
if exist(sprintf('%d.mat',data(i)), 'file')==0
Slambda_Al(data(i),n);
end
fprintf('%d of %d\n',i,length1);
end
I get this error if the current directory contains a ".m" file otherwise runs without errors.
Error using Iteration (line 21)
Too many input arguments.

7 件のコメント

Jan
Jan 2019 年 4 月 19 日
編集済み: Jan 2019 年 4 月 19 日
Please mention, which one the "line 21" is. You have posted 11 lines only. Posting the complete error message is a good idea. Which m-files exist in the current folder?
Adel Sarhan
Adel Sarhan 2019 年 4 月 19 日
this is the complete error message
line 21 is marked with a comment, It's the one starting with parfor
the mat files is where my calculation are previuosly saved. I use the "if exist" to check if the current point already calculated to skip the calculation to the next point of the data.
Walter Roberson
Walter Roberson 2019 年 4 月 19 日
How many arguments does Slambda_Al accept?
Adel Sarhan
Adel Sarhan 2019 年 4 月 19 日
two
function Slambda_Al(lambd,n)
Walter Roberson
Walter Roberson 2019 年 4 月 19 日
When you say that you get the problem when the directory contains a ".m" file, do you mean that you could set up a situation where the directory contained no .m files and the code would work, but if you were to create ThIsIsAnUnUsEdFiLe.m with empty content, then the parfor would fail ?
Adel Sarhan
Adel Sarhan 2019 年 4 月 19 日
sorry I meant to say a . mat files of previously calculated data.
Walter Roberson
Walter Roberson 2019 年 4 月 19 日
For the purpose of debugging, try commenting out the SLambda_Al call, and instead displaying to i and n values, and seeing if the problem still happens. If it does not still happen then the problem would seem to be associated with the call to SLambda_Al , in which case you could try calling it with constant values like Slambda_al(1,1) and see if the problem still occurred.
I wonder if the problem is actually inside Slambda_al ?

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeParallel for-Loops (parfor) についてさらに検索

製品

リリース

R2018a

タグ

質問済み:

2019 年 4 月 19 日

コメント済み:

2019 年 4 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by