What is my errror, getting the message "Reference to non-existent field 'F'"??

2 views (last 30 days)
I am getting the referenced message unexpectly (sometimes yes, sometimes no!!) with R2010b and R2013b Matlab versions. Unbelievably with an older Matlab version like R2007a, the program works fine and this message is not showed when I run the same code.
Attached is the code and error message in order to ask you some advise for fixing this error.
load BynaryData.dat %Abrir Archivo Datos Binarios. x1exp=BynaryData(:,1); %x1 Experimental y1exp=BynaryData(:,2); %y1 Experimental Pexp=BynaryData(:,3); %Presion Experimental Ndatos=size(Pexp);Ndatos=Ndatos(1); load CompData.dat %Abrir Archivo Datos de Compuestos. T=CompData(1,1); %Temperatura R=CompData(1,2); %Constante de Gases Pc1=CompData(2,1); %Presion Critica 1 Pc2=CompData(2,2); %Presion Critica 2 Tc1=CompData(3,1); %Temperatura Critica 1 Tc2=CompData(3,2); %Temperatura Critica 2 ww1=CompData(4,1); %Factor Acentrico 1 ww2=CompData(4,2); %Factor Acentrico 2 load UniquacData.dat; %Abrir Archivo Datos de Uniquac. U=UniquacData; x1=x1exp; x2=1-x1; y2exp=1-y1exp; Epsilon=1-sqrt(2); Sigma=1+sqrt(2); X=[x1 x2 y1exp y2exp Pexp];Y=[3.2 0.3]; Z=[Pc1 Pc2 Tc1 Tc2 ww1 ww2];W=[T R Ndatos];Var=6; Pc=UNIQUAC(X,Y,Z,W,1,U); SSE=@(Y)UNIQUAC(X,Y,Z,W,6,U); [Y,SSE]=lsqnonlin(SSE,Y); Pc=UNIQUAC(X,Y,Z,W,1,U);y1c=UNIQUAC(X,Y,Z,W,2,U); dP=Pexp-Pc;dy=y1exp-y1c;K1=UNIQUAC(X,Y,Z,W,3,U); K2=UNIQUAC(X,Y,Z,W,4,U);SUM=UNIQUAC(X,Y,Z,W,5,U); RMSdP=((sum(dP.^2))/Ndatos)^0.5;RMSdy=((sum(dy.^2))/Ndatos)^0.5; Resultados=([x1';Pc';y1c';K1';K2';SUM']); Resultados1=([x1';Pexp';Pc';dP']); Resultados2=([x1';y1exp';y1c';dy']); fileID = fopen('Results_UNIQUAC.txt','w'); fprintf(fileID,'%40s\r\n','Sistema Etanol-Hexano a 40 ºC'); fprintf(fileID,'%36s\r\n','Resultados Correlacionados'); fprintf(fileID,'%32s\r\n \r\n','Método de UNIQUAC'); fprintf(fileID,'%22s %6s\r\n','t12','t21'); fprintf(fileID,'%23.4f %7.4f\r\n \r\n',Y); fprintf(fileID,'%5s %8s %7s %7s %7s %7s\r\n','x1','Pcal','y1c','K1','K2','SUM'); fprintf(fileID,'%7.4f %8.4f %7.4f %7.4f %7.4f %7.4f\r\n',Resultados); fprintf(fileID,'\r\n'); fprintf(fileID,'%5s %9s %7s %6s \r\n','x1','Pexp','Pcal','dP'); fprintf(fileID,'%7.4f %8.4f %7.4f %7.4f\r\n',Resultados1); fprintf(fileID,'\r\n %8s \r\n','RMSdP'); fprintf(fileID,'%10.4f\r\n',RMSdP); fprintf(fileID,'\r\n'); fprintf(fileID,'%5s %9s %7s %5s \r\n','x1','y1exp','y1cal','dy'); fprintf(fileID,'%7.4f %7.4f %7.4f %7.4f\r\n',Resultados2); fprintf(fileID,'\r\n %8s \r\n','RMSdy'); fprintf(fileID,'%10.4f\r\n',RMSdy); fclose(fileID); xp=[0:0.001:1];Pc=interp1(x1,Pc,xp,'pchip');y1c=interp1(x1,y1c,xp,'pchip'); set(figure,'Color',[1 1 1]) plot(x1,Pexp,'bo',y1exp,Pexp,'rs',xp,Pc,'k-',y1c,Pc,'b--') title('EVL de Etanol(1)/Hexano(2) @ 40ºC usando PR-qE con el modelo de UNIQUAC') xlabel('Fracción Molar (x1,y1)') ylabel('Presión (bar)') legend('Datos Px Experimentales','Datos Py Experimentales','Datos Px Calculados','Datos Py Calculados') legend('Location','SouthWest') grid on set(figure,'Color',[1 1 1]) s(1) = subplot(2,1,1); s(2) = subplot(2,1,2); plot(s(1),x1,dP*10,'bx',x1,zeros(Ndatos),'k:') title(s(1),'EVL de Etanol(1)/Hexano(2) @ 40ºC usando PR-qE con el modelo de UNIQUAC') xlabel(s(1),'Fracción Molar (x1,y1)') ylabel(s(1),'Residual de Presión (10*bar)') plot(s(2),x1,dy*100,'g+',x1,zeros(Ndatos),'k:') title(s(2),'EVL de Etanol(1)/Hexano(2) @ 40ºC usando PR-qE con el modelo de UNIQUAC') xlabel(s(2),'Fracción Molar (x1,y1)') ylabel(s(2),'Residual de y1*10^2')
Error Message:
??? Reference to non-existent field 'F'.
Error in ==> lsqncommon at 14 [sizes.fRows,sizes.fCols] = size(initVals.F);
Error in ==> lsqnonlin at 169 [x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in ==> EthanolHexane_40C_qE_UNIQUAC at 23 [Y,SSE]=lsqnonlin(SSE,Y);

Answers (1)

Image Analyst
Image Analyst on 5 Nov 2013
Your variable initVals does not have a field F as a member. Why do you think it should? Put this right before the line where it throws and error:
whos initVals
initVals

Categories

Find more on File Operations 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!