Te_ece_jd

PURPOSE ^

SYNOPSIS ^

function [tTe0,tTea,teTe1,teTe2] = Te_ece_jd(equil,cR,ctece,display_mode)

DESCRIPTION ^

 initial guess

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tTe0,tTea,teTe1,teTe2] = Te_ece_jd(equil,cR,ctece,display_mode)
0002 %
0003 % initial guess
0004 %
0005 if nargin < 4,
0006     display_mode = 0;
0007 end
0008 %
0009 nt = size(ctece,2);
0010 %
0011 ap = equil.ptx(end,1);
0012 rho = equil.ptx(:,1)/ap;
0013 %
0014 if mean(cR(~isnan(cR))) > equil.Rp,% LFS measurements
0015     crho0 = (cR - equil.Rp)/ap;
0016     cmask0 = crho0 >= 0 & crho0 <= 1;% HFS measurements
0017 else
0018     crho0 = interp1(equil.ptx(:,(end+1)/2),rho,cR - equil.Rp,'linear','extrap');
0019     cmask0 = crho0 >= 0 & crho0 <= 1;% HFS measurements
0020 end    
0021 %
0022 for it = 1:nt,
0023     %
0024     cece = ctece(:,it);
0025     %
0026     cmask = cmask0 & cece > 0; 
0027     %
0028     crho = crho0(cmask);
0029     cece = cece(cmask);
0030     %
0031     [crho,ic] = sort(crho);
0032     cece = cece(ic);
0033     %
0034     Te0 = max(cece,[],1);
0035     Tea = min(cece,[],1);
0036     %
0037     eTe1 = 2;
0038     eTe2 = 2;
0039     %
0040     crho = [0;crho;1];
0041     cece = [Te0;cece;Tea];
0042     %
0043     %plot(crho,cece,'ro'); hold on; h = plot(crho,cece,'b'); hold off;
0044     %
0045     start = [Te0,Tea,eTe1,eTe2];
0046     %outputFcn = @(x,optimvalues,state) fitoutputfun(x,optimvalues,state,crho,cece);
0047     %options = optimset('OutputFcn',outputFcn,'TolX',0.1);
0048     options = optimset('TolX',0.1);
0049     %
0050     y = fminsearch(@(x)err_Tenefit_jd(x,crho,cece),start,options);
0051     tTe0(it) = y(1);
0052     tTea(it) = y(2);
0053     teTe1(it) = y(3);
0054     teTe2(it) = y(4);
0055     %
0056     if display_mode >= 2,
0057         %
0058         rho = 0:0.001:1;
0059         figure(it),clf
0060         plot(crho,cece,'ro',rho,Tenefit_jd(rho,tTe0(it),tTea(it),teTe1(it),teTe2(it)),'b-')
0061         %
0062     end
0063     %
0064 end
0065 %
0066 
0067 
0068 %

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.