# PDE toolbox: Undefined function 'mtimes' for input arguments of type 'function_handle'.

14 views (last 30 days)
Flo brd on 2 Oct 2018
Commented: Flo brd on 3 Oct 2018
Hi everyone,
I have a bit of a hard time finding a way to use the output of my function handle:
effStress = @(~,state) (2700*9.81*4000*1e-6)-state.u;
K = 1e-12-(0.04343*((0.012+0.013)/2));
Dcore=(K*effStress);
I understand that I apparently cannot multiply K with effStress, but even a matrix multiplication doesnt work.
Could anyone help me on that?
Cheers, Flo
##### 2 CommentsShowHide 1 older comment
Flo brd on 2 Oct 2018
I did try something similar. It didn't work. My issue is that I am working with the PDE toolbox. I am trying to apply a non-constant variable (with the C coefficient if that helps)

Stephen Cobeldick on 2 Oct 2018
Edited: Stephen Cobeldick on 2 Oct 2018
A function handle is not a numeric array, it cannot be multiplied. You could either
1. evaluate the function to get a numeric value, and multiply that value:
>> S.u = 4;
>> effStress = @(~,state) (2700*9.81*4000*1e-6)-state.u;
>> K = 1e-12-(0.04343*((0.012+0.013)/2));
>> K*effStress(0,S) % evaluate effStress to get an output.
ans = -0.055345
2. define a new function that calls your function:
>> fun = @(s)K*effStress(0,s); % does not evaluate effStress.
>> fun(S)
ans = -0.055345
Flo brd on 3 Oct 2018
I changed a bit my function, following what I've understood from the matlab help (and I am pretty my understanding is wrong), and my error changed to a warning. it doesn't compile but maybe you help me on that one too. here is my function:
function Dh = Diffusivity(location,state,ki, depth,density, T)
N = 1; % Number of equations
nr = numel(location.x); % Number of columns
Dh = zeros(N,nr); % Allocate to avoid size issue
% Eff(1,:) = ones(1,nr);
confiningStress = density*9.81*depth*1e-6;
matConf = zeros(1,nr);
matConf(1,:)=confiningStress;
Cp = 0.000000001;
T = T+273.15;
A=2.414*10^-5;
B=247.8;
C=140;
%temperature dependent viscosity
u = A*10^(B/(T-C));
%pressure dependent k
gamma =0.1
Dh(1,:)=(ki-(0.2*gamma.*(matConf(1,:) - state.u(1,:))))./(u*Cp);
end
the error is now
Warning: Failure at t=1.132789e-12. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (3.231174e-27) at time t.
I am completely lost.
Flo