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

Hi everyone.
Cant find the problem in the function :(((
b=400; %mm
d=500; %mm
Asv = [3000 5000 3000 5000]; %mm^2
fckv = [30 30 90 90]; %Mpa
num_fckv = numel(fckv);
fsolve_opts = optimoptions('fsolve','Display','off');
c0 = 100;
tic
for k = 1:num_fckv
fck = fckv(k);
Ecshah=57000/145*(fck*145)^0.5; %Mpa
Es=200000; %Mpa
Esh=8500; %Mpa
fy=500; %Mpa
fsu=750; %Mpa
epssh=0.009;
epssu=0.075;
eps0=1.027*10^-7*fck*145+0.00195;
kshah=0.025*fck*10^3;
A=Ecshah*eps0/fck;
P=Esh*((epssu-epssh)/(fsu-fy));
epsy=fy/Es;
As = Asv(k);
%Values at yield
epssAtMy= epsy;
epscmAtMy=@(cAtMy) epssAtMy*cAtMy./(d-cAtMy);
funCshahAtMy=@(epsc) (1-(1-epsc./eps0).^A) .* (epsc<=eps0) + exp(-kshah*(epsc-eps0).^1.15) .* (epsc>eps0);
compressionAtMy=@(cAtMy) b*fck*cAtMy/epscmAtMy(cAtMy)*integral(funCshahAtMy,0,epscmAtMy(cAtMy))/1000;
%compressionAtMy=@(cAtMy) b*fck*cAtMy/epscmAtMy*integral(funCshahAtMy,0,epscmAtMy)/1000;
sigmaSteelAtMy= fy;
tensionAtMy= sigmaSteelAtMy*As/1000;
cAtMy(k)=fsolve(@(cAtMy) compressionAtMy(cAtMy)-tensionAtMy, c0, fsolve_opts)
c0=cAtMy(k);
funM=@(epsc) (1-(1-epsc./eps0).^A).*(d-cAtMy(k)+(cAtMy(k)./epscmAtMy).*epsc) .* (epsc<=eps0) + exp(-kshah*(epsc-eps0).^1.15).*(d-cAtMy(k)+(cAtMy(k)./epscmAtMy).*epsc) .* (epsc>eps0);
M(k)=b*fck*cAtMy(k)/epscmAtMy*integral(funM,0,epscmAtMy)/1000000
end
toc
Error:
Undefined operator '/' for input arguments of type 'function_handle'.
Error in Untitled (line 39)
M(k)=b*fck*cAtMy(k)/epscmAtMy*integral(funM,0,epscmAtMy)/1000000

 Accepted Answer

b=400; %mm
d=500; %mm
Asv = [3000 5000 3000 5000]; %mm^2
fckv = [30 30 90 90]; %Mpa
num_fckv = numel(fckv);
fsolve_opts = optimoptions('fsolve','Display','off');
c0 = 100;
tic
for k = 1:num_fckv
fck = fckv(k);
Ecshah=57000/145*(fck*145)^0.5; %Mpa
Es=200000; %Mpa
Esh=8500; %Mpa
fy=500; %Mpa
fsu=750; %Mpa
epssh=0.009;
epssu=0.075;
eps0=1.027*10^-7*fck*145+0.00195;
kshah=0.025*fck*10^3;
A=Ecshah*eps0/fck;
P=Esh*((epssu-epssh)/(fsu-fy));
epsy=fy/Es;
As = Asv(k);
%Values at yield
epssAtMy= epsy;
epscmAtMy=@(cAtMy) epssAtMy*cAtMy./(d-cAtMy);
funCshahAtMy=@(epsc) (1-(1-epsc./eps0).^A) .* (epsc<=eps0) + exp(-kshah*(epsc-eps0).^1.15) .* (epsc>eps0);
compressionAtMy=@(cAtMy) b*fck*cAtMy/epscmAtMy(cAtMy)*integral(funCshahAtMy,0,epscmAtMy(cAtMy))/1000;
%compressionAtMy=@(cAtMy) b*fck*cAtMy/epscmAtMy*integral(funCshahAtMy,0,epscmAtMy)/1000;
sigmaSteelAtMy= fy;
tensionAtMy= sigmaSteelAtMy*As/1000;
cAtMy(k)=fsolve(@(cAtMy) compressionAtMy(cAtMy)-tensionAtMy, c0, fsolve_opts)
c0=cAtMy(k);
funM=@(epsc) (1-(1-epsc./eps0).^A).*(d-cAtMy(k)+(cAtMy(k)./epscmAtMy(cAtMy(k))).*epsc) .* (epsc<=eps0) + exp(-kshah*(epsc-eps0).^1.15).*(d-cAtMy(k)+(cAtMy(k)./epscmAtMy(cAtMy(k))).*epsc) .* (epsc>eps0);
M(k)=b*fck*cAtMy(k)/epscmAtMy(cAtMy(k))*integral(funM,0,epscmAtMy(cAtMy(k)))/1000000
end
toc

3 Comments

Hi Stephan. i tryed it but it Errors:
Conversion to function_handle from double is not possible.
Error in Untitled3 (line 35)
M(k)=b*fck*cAtMy(k)/epscmAtMy(cAtMy(k))*integral(funM,0,epscmAtMy(cAtMy(k)))/1000000
For me the code works free of errors:
cAtMy =
213.5338
M =
633.3242
cAtMy =
213.5338 283.4136
M =
633.3242 958.8101
cAtMy =
213.5338 283.4136 157.4791
M =
633.3242 958.8101 669.5751
cAtMy =
213.5338 283.4136 157.4791 195.2034
M =
1.0e+03 *
0.6333 0.9588 0.6696 1.0822
Elapsed time is 0.443724 seconds.
Thank you Very much! i tryed it again and it worked.
Thank you

Sign in to comment.

More Answers (0)

Categories

Find more on Parallel Computing Toolbox 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!