Azzera filtri
Azzera filtri

I am using parfor and fminsearch. The error massege is "An UndefinedFunction error was thrown on the workers for 'x'....'

2 visualizzazioni (ultimi 30 giorni)
Hello. I am in trouble with an error message as following:
-----------------------------------------------------------------
Analyzing and transferring files to the workers ...done. Error using EXTRACTION (line 834) An UndefinedFunction error was thrown on the workers for 'x'. This might be because the file containing 'x' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached. See the documentation for 'parallel.Pool/addAttachedFiles' for more details.
Caused by: Undefined function 'x' for input arguments of type 'double'.
--------------------------------------------------------------
I am using 'parfor' and 'fminsearch' in my code. The code is shown in below.
parfor b=1:7953
Ra=x(1);
Rb=x(2);
La=x(3);
Lb=x(4);
Ga=x(5);
Gb=x(6);
Ca=x(7);
Cb=x(8);
R=[Ra, Rb, Rb; Rb, Ra, Rb; Rb, Rb, Ra;];
L=[La, Lb, Lb; Lb, La, Lb; Lb, Lb, La;];
G=[Ga, Gb, Gb; Gb, Ga, Gb; Gb, Gb, Ga;];
C=[Ca, Cb, Cb; Cb, Ca, Cb; Cb, Cb, Ca;];
Z=R+1i*wm(b,1).*L;
Y=G+1i*wm(b,1).*C;
Gamma=sqrtm(Z*Y);
Zc=Gamma/Y;
RLGC=abs(real(Zc_A_11(b,1))-real(Zc(1,1)))+abs(imag(Zc_A_11(b,1))-imag(Zc(1,1)))+abs(real(Zc_A_12(b,1))-real(Zc(1,2)))+abs(imag(Zc_A_12(b,1))-imag(Zc(1,2)));
x0=[R_open(b,1), R_open(b,1)*0.1, L_open(b,1), L_open(b,1)*0.1, G_open(b,1), G_open(b,1)*0.1, C_open(b,1), C_open(b,1)*0.1];
x=fminsearch(RLGC, x0, optimset('MaxFunEvals', 1e10, 'MaxIter', 1e7, 'TolX', 1e-7));
Ra_num(b,1)=x(1);
Rb_num(b,1)=x(2);
La_num(b,1)=x(3);
Lb_num(b,1)=x(4);
Ga_num(b,1)=x(5);
Gb_num(b,1)=x(6);
Ca_num(b,1)=x(7);
Cb_num(b,1)=x(8);
end
where wm, Zc_A_11, Zc_A_12 are calculated values before the shown code. I have no idea what I am doing wrong. Someone help me please. Please give me an advise or fix my code. It will be very helpful for me. Thank you..
  2 Commenti
Joshua Wysack
Joshua Wysack il 1 Mag 2015
I'm having a similar issue, I've found that if I alter the the code being run in parallel in any way and rerun it, it works correctly. I deleted a spacer line at one point and mine started running in parallel correctly. I'm not sure why this is, but it may provide more information to try and find a cause/solution.
My UndefinedFunction is a Java class by the way.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Optimization Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by