0001 function [varargout] = calcval_yp(fit,theta,a0,an,bn,da0drho,dandrho,dbndrho,d2a0drho2,d2andrho2,d2bndrho2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if isfield(fit,'x_fit'), fit = fit.x_fit;end
0023
0024 if nargin ~= 11 & nargin ~= 8 & nargin ~= 5,error('Wrong number of input arguments in calcval_yp.m');end
0025
0026 if size(an,2) ~= size(fit.n,1), an = an.';end
0027 if size(bn,2) ~= size(fit.n,1), bn = bn.';end
0028
0029 if nargin >= 8,
0030 if size(dandrho,2) ~= size(fit.n,1), dandrho = dandrho.';end
0031 if size(dbndrho,2) ~= size(fit.n,1), dbndrho = dbndrho.';end
0032 end
0033
0034 if nargin == 11,
0035 if size(d2andrho2,2) ~= size(fit.n,1), d2andrho2 = d2andrho2.';end
0036 if size(d2bndrho2,2) ~= size(fit.n,1), d2bndrho2 = d2bndrho2.';end
0037 end
0038
0039 n = fit.n;
0040
0041 Xa0 = repmat(a0(:),[1,size(theta,1),size(theta,2)]);
0042
0043 Zan = repmat(an,[1,1,size(theta,1),size(theta,2)]);
0044 Zbn = repmat(bn,[1,1,size(theta,1),size(theta,2)]);
0045
0046 Zn = permute(repmat(n(:),[1,size(a0(:),1),size(theta,1),size(theta,2)]),[2,1,3,4]);
0047
0048 Ztheta = permute(repmat(theta,[1,1,size(a0(:),1),size(n(:),1)]),[3,4,1,2]);
0049
0050 X = squeeze(Xa0) + squeeze(sum(Zan.*cos(Zn.*Ztheta),2)) + squeeze(sum(Zbn.*sin(Zn.*Ztheta),2));
0051 dXdtheta = -squeeze(sum(Zan.*(Zn.*sin(Zn.*Ztheta)),2)) + squeeze(sum(Zbn.*(Zn.*cos(Zn.*Ztheta)),2));
0052 d2Xdtheta2 = -squeeze(sum(Zan.*(Zn.^2.*cos(Zn.*Ztheta)),2)) - squeeze(sum(Zbn.*(Zn.^2.*sin(Zn.*Ztheta)),2));
0053
0054 if nargin >= 8,
0055 if ~isempty(da0drho) & ~isempty(dandrho) & ~isempty(dbndrho),
0056
0057 Xda0drho = repmat(da0drho(:),[1,size(theta,1),size(theta,2)]);
0058 Zdandrho = repmat(dandrho,[1,1,size(theta,1),size(theta,2)]);
0059 Zdbndrho = repmat(dbndrho,[1,1,size(theta,1),size(theta,2)]);
0060
0061 dXdrho = squeeze(Xda0drho) + squeeze(sum(Zdandrho.*cos(Zn.*Ztheta),2)) + squeeze(sum(Zdbndrho.*sin(Zn.*Ztheta),2));
0062 d2Xdthetadrho = squeeze(sum(-Zdandrho.*(Zn.*sin(Zn.*Ztheta)),2)) + squeeze(sum(Zdbndrho.*(Zn.*cos(Zn.*Ztheta)),2));
0063
0064 else
0065
0066 dXdrho = [];
0067 d2Xdthetadrho = [];
0068
0069 end
0070 end
0071
0072 if nargin == 11,
0073 if ~isempty(d2a0drho2) & ~isempty(d2andrho2) & ~isempty(d2bndrho2),
0074
0075 Xd2a0drho2 = repmat(d2a0drho2(:),[1,size(theta,1),size(theta,2)]);
0076 Zd2andrho2 = repmat(d2andrho2,[1,1,size(theta,1),size(theta,2)]);
0077 Zd2bndrho2 = repmat(d2bndrho2,[1,1,size(theta,1),size(theta,2)]);
0078
0079 d2Xdrho2 = squeeze(Xd2a0drho2) + squeeze(sum(Zd2andrho2.*cos(Zn.*Ztheta),2)) + squeeze(sum(Zd2bndrho2.*sin(Zn.*Ztheta),2));
0080 else
0081 d2Xdrho2 = [];
0082 end
0083 end
0084
0085 if nargout >= 1 & nargin >=5, varargout{1} = X;end
0086 if nargout >= 2 & nargin >=5, varargout{2} = dXdtheta;end
0087 if nargout >= 3 & nargin >=5, varargout{3} = d2Xdtheta2;end
0088 if nargout >= 4 & nargin >= 8, varargout{4} = dXdrho;end
0089 if nargout >= 5 & nargin >= 8, varargout{5} = d2Xdthetadrho;end
0090 if nargout >= 6 & nargin == 11, varargout{6} = d2Xdrho2;end
0091
0092