Undefined operator './' for input arguments of type 'function_handle'.

조회 수: 7 (최근 30일)
guest10011
guest10011 2018년 10월 31일
댓글: Walter Roberson 2018년 11월 1일
Hello,
The part of the code I developed is exhibited below:
deriv1 = @(x) (sum(log(ti(x))-log(x(2))-(x(3)./Ti)-(x(4)./Vi)-log(tj(x)./(log(x(2))+(x(3)./Tj)+(x(4)./Vj))).*(tj./(log(x(2))+(x(3)./Tj)+x(4)./Vj)).^x(1))+sum(- log(ti(x)./(log(x(2))+x(3)./Vi + x(4)./Vi)).*(ti(x)./(log(x(2))+ x(3)./Vi + x(4)./Vi)).^x(1) + 1./x(1)));
% Derivative dL/dA
%deriv2 = @(x) -(x(1).*(sum((Vj.^x(3).*tj(x).*x(2)).^x(1))+sum((Vi.^x(3).*ti(x).*x(2)).^x(1))-1))./x(2);
deriv2 = @(x) (sum((x(1).*tj(x).*(tj(x)./(log(x(2)) + x(3)./Tj + x(4)./Vj)).^(x(1) - 1))./(x(2).*(log(x(2)) + x(3)./Tj + x(4)./Vj).^2) - x(1)./x(2)) + sum((x(1).*ti(x).*(ti(x)./(log(x(2)) + x(3)./Vi + x(4)./Vi)).^(x(1) - 1))./(x(2).*(log(x(2)) + x(3)./Vi + x(4)./Vi).^2)));
% Derivative dL/dx(3)
deriv3 = @(x) (sum((x(1).*tj(x).*(tj(x)./(log(x(2)) + x(3)./Tj + x(4)./Vj)).^(x(1) - 1))./(Tj.*(log(x(2)) + x(3)./Tj + x(4)./Vj).^2)) + sum (- x(1)./Ti + (x(1).*ti(x).*(ti(x)./(log(x(2)) + x(3)./Vi + b./Vi)).^(x(1) - 1))./(Vi*(log(x(2)) + x(3)./Vi + x(4)./Vi).^2)));
% Derivative dL/b
deriv4 = @(x) (sum((x(1).*tj(x).*(tj(x)./(log(x(2)) + x(3)./Tj + x(4)./Vj)).^(x(1) - 1))./(Vj.*(log(x(2)) + x(3)./Tj + x(4)./Vj).^2)) + sum( - x(1)./Vi + (x(1).*ti(x).*(ti(x)./(log(x(2)) + x(3)./Vi + x(4)./Vi)).^(x(1) - 1))./(Vi.*(log(x(2)) + x(3)./Vi + x(4)./Vi).^2)));
I keep receiving the error message:
Undefined operator './' for input arguments of type 'function_handle'.
Error in
Example>@(x)(sum(log(ti(x))-log(x(2))-(x(3)./Ti)-(x(4)./Vi)-log(tj(x)./(log(x(2))+(x(3)./Tj)+(x(4)./Vj))).*(tj./(log(x(2))+(x(3)./Tj)+x(4)./Vj)).^x(1))+sum(-log(ti(x)./(log(x(2))+x(3)./Vi+x(4)./Vi)).*(ti(x)./(log(x(2))+x(3)./Vi+x(4)./Vi)).^x(1)+1./x(1)))
I was wondering where I was making the mistake. I have checked this part several times. Any help will be appreciated.
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 10월 31일
My guess is that Ti is a function handle and that where you refer to Ti you should have Ti(x)
guest10011
guest10011 2018년 11월 1일
Here are the full codes.
clc
clear
% ========================================================================
% Initialize data and constants
% ========================================================================
% Definitions of different variables used in this code
% x(1): beta parameter
% x(2): A parameter
% x(3): Fi parameter
% x(4): b parameter
% Stress Levels 1 through 4 in Kelvin
T = [65 75 85 95] + 273.15;
V = [0.7 0.8 0.85 0.95];
% The end time of each of the Stress Levels 1 through 3 (in hours)
tend = [7 18 22 24 26];
% Times to failure
TTF = [15 18 22 24 28 30 33]';
% ========================================================================
% The next step is to define the the failure and survival times as well as
% failure and survival stress levels for each of the six step stress
% levels.
% ========================================================================
% STEP 1:
% Failure Times in hours
TTF1=0;
% Survival times in hours
TTS1 = tend(1).*ones(15,1);
% Failure Stress (V)
VF1 = 0;
MF1 = 0;
% Survival Stress (V)
VS1 = T(1).*ones(15,1);
MS1 = V(1).*ones(15,1);
% STEP 2:
% Failure Times in hours
TTF2 = TTF(1:2);
% Survival times in hours
TTS2 = tend(2).*ones(13,1);
% Failure Stress (Kelvin)
VF2 = T(2).*ones(2,1);
MF2 = V(2).*ones(2,1);
% Survival Stress (Kelvin)
VS2 = T(2).*ones(13,1);
MS2 = T(2).*ones(13,1);
% STEP 3:
% Failure Times in hours
TTF3 = TTF(3:5);
% Survival times in hours
TTS3 = tend(3).*ones(10,1);
% Failure Stress (Kelvin)
VF3 = T(3).*ones(3,1);
MF3 = V(3).*ones(3,1);
% Survival Stress (Kelvin)
VS3 = T(3).*ones(10,1);
MS3= V(3).*ones(10,1);
% STEP 4:
% Failure Times in hours
TTF4 = TTF(5:7);
% Survival times in hours
TTS4 = tend(4).*ones(7,1);
% Failure Stress (Kelvin)
VF4 = T(4).*ones(3,1);
MF4 = V(4).*ones(3,1);
% Survival Stress (Kelvin)
VS4 = T(4).*ones(7,1);
MS4 = V(4).*ones(7,1);
% ========================================================================
% SETUP FOR TAU (tau1 through tau5 for stress levels 2 through 6
% This establishes the equivalent time (tau_(i-1)) of step i-1 if the item
% is operated at step stress level i.
% tau for step 2
tau1 = @(x) (tend(1)).*exp(x(3).*(1./T(2) - 1./T(1)) + x(4).*(1./V(2) - 1./V(1)));
% tau for step 3
tau2 = @(x) (tend(2)-tend(1)+tau1(x)).*exp(x(3).*(1./T(3) - 1./T(2)) + x(4).*(1./V(3) - 1./V(2)));
% tau for step 4
tau3 = @(x) (tend(3)-tend(2)+tau2(x)).*exp(x(3).*(1./T(4) - 1./T(3)) + x(4).*(1./V(4) - 1./V(3)));
% ========================================================================
% SETUP FOR ADJUSTED TIME VECTORS
tvecti = [0;tend(1).*ones(2,1);tend(2).*ones(3,1);tend(3).*ones(3,1)];
tvectj = [zeros(15,1);tend(1).*ones(13,1);tend(2).*ones(10,1);tend(3).*ones(7,1)];
taui = @(x) [tau1(x);tau1(x);tau2(x);tau2(x);tau2(x);tau2(x);tau3(x);tau3(x);tau3(x)];
tauj = @(x) [zeros(15,1);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau1(x);tau2(x);tau2(x);tau2(x);tau2(x);tau2(x);tau2(x);tau2(x);tau2(x);tau2(x);tau2(x);tau3(x);tau3(x);tau3(x);...
tau3(x);tau3(x);tau3(x);tau3(x)];
ti = @(x) [TTF1;TTF2;TTF3;TTF4] - tvecti + taui(x);
tj = @(x) [TTS1;TTS2;TTS3;TTS4] - tvectj + tauj(x);
% The failure and survival stress levels are assigned a vector of the same
% sizes as the adjusted time vectors for the MLE operation.
Ti = [VF1;VF2;VF3;VF4];
Tj = [VS1;VS2;VS3;VS4];
Vi = [MF1;MF2;MF3;MF4];
Vj = [MS1;MS2;MS3;MS4];
% ========================================================================
% SETUP FOR DERIVATIVES
% Derivative dL/dbeta
% deriv1 = @(x)
% -((sum((x(2).*Vj.^x(3).*tj(x)).^x(1).*log(x(2).*Vj.^x(3).*tj(x)))+sum((x(2).*Vi.^x(3).*ti(x)).^x(1).*log(x(2).*Vi.^x(3).*ti(x))-log(x(2).*Vi.^x(3).*ti(x)))).*x(1)-1)./x(1);
deriv1 = @(x) (sum(log(ti(x))-log(x(2))-(x(3)./Ti)-(x(4)./Vi)-log(tj(x)./(log(x(2))+(x(3)./Tj)+(x(4)./Vj))).*(tj./(log(x(2))+(x(3)./Tj)+x(4)./Vj)).^x(1))+sum(- log(ti(x)./(log(x(2))+x(3)./Vi + x(4)./Vi)).*(ti(x)./(log(x(2))+ x(3)./Vi + x(4)./Vi)).^x(1) + 1./x(1)));
% Derivative dL/dA
%deriv2 = @(x) -(x(1).*(sum((Vj.^x(3).*tj(x).*x(2)).^x(1))+sum((Vi.^x(3).*ti(x).*x(2)).^x(1))-1))./x(2);
deriv2 = @(x) (sum((x(1).*tj(x).*(tj(x)./(log(x(2)) + x(3)./Tj + x(4)./Vj)).^(x(1) - 1))./(x(2).*(log(x(2)) + x(3)./Tj + x(4)./Vj).^2) - x(1)./x(2)) + sum((x(1).*ti(x).*(ti(x)./(log(x(2)) + x(3)./Vi + x(4)./Vi)).^(x(1) - 1))./(x(2).*(log(x(2)) + x(3)./Vi + x(4)./Vi).^2)));
% Derivative dL/dx(3)
deriv3 = @(x) (sum((x(1).*tj(x).*(tj(x)./(log(x(2)) + x(3)./Tj + x(4)./Vj)).^(x(1) - 1))./(Tj.*(log(x(2)) + x(3)./Tj + x(4)./Vj).^2)) + sum (- x(1)./Ti + (x(1).*ti(x).*(ti(x)./(log(x(2)) + x(3)./Vi + b./Vi)).^(x(1) - 1))./(Vi*(log(x(2)) + x(3)./Vi + x(4)./Vi).^2)));
% Derivative dL/b
deriv4 = @(x) (sum((x(1).*tj(x).*(tj(x)./(log(x(2)) + x(3)./Tj + x(4)./Vj)).^(x(1) - 1))./(Vj.*(log(x(2)) + x(3)./Tj + x(4)./Vj).^2)) + sum( - x(1)./Vi + (x(1).*ti(x).*(ti(x)./(log(x(2)) + x(3)./Vi + x(4)./Vi)).^(x(1) - 1))./(Vi.*(log(x(2)) + x(3)./Vi + x(4)./Vi).^2)));
% Derivative vector [dL/dbeta;dL/dK;dL/dn]
F1 = @(x) [deriv1(x);deriv2(x);deriv3(x);deriv4(x)];
% Initial estimate for parameters
x0 = [2 1e-14 10 10];
% initialize PARAMHAT estimates
paramhatv = x0;
for i = 1:100
if i == 1
paramhat = fsolve(F1,x0);
else
paramhat = fsolve(F1,paramhat);
end
paramhatv(i+1,:) = paramhat;
end
% Display the derivative vector based on the PARAMHAT estimate
F1(paramhat)

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 11월 1일
(tj./(log(x(2))+(x(3)./Tj)+x(4)./Vj))
Has function handle tj divided by something
  댓글 수: 3
guest10011
guest10011 2018년 11월 1일
Thank you! I understand now.
Walter Roberson
Walter Roberson 2018년 11월 1일
tj(x) instead of tj in that context.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by