I want to solve this equation in MATLAB:
term2 = for k=1:numel(j) (prod(D(k,:)==exp(P(1).*c.*(log(P(1)).^k/factorial(k))))) endterm1= exp(-(lambda*P(1).*pi.*(r.^2)))
I'm trying to do that:
function F = root2d(P); lambda = 2*10^-4;th = -40:-1:-106;PL1 = 10471285.480509; % (mw)
p1 = 10;p2 = 6 ; p3 = 8 ; al = 2.5;T = 10.^(th./10);r = (p1*PL1^(-1)./T).^(1/al);R = (p2*PL1^(-1)./T).^(1/al);syms Pc = (lambda.*pi.*(R.^2));j = 1:3;D = zeros(3,67);for k = 1:numel(j) F(1) = (prod(D(k,:)==exp(P(1).*c.*(log(P(1)).^k/factorial(k))))).*exp(-(lambda*P(1).*pi.*(r.^2)))-P;end %fun = @root2d; in the command line
%P0 = 0; in the command line
%P = fsolve(fun,P0) in the command line
when th = -40
Error using fsolve (line 269)FSOLVE requires all values returned by functions to be of data type double end.but when th is a vector (1*67)double (th = -40:-1:-106)Error in fsolve (line 230) fuser = feval(funfcn{3},x,varargin{:});Caused by: Failure in initial objective function evaluation. FSOLVE cannot continue.`Do you have an idea?
Best Answer