Why I got the error "Undefined operator '.*' for input arguments of type 'function_handle"?

4 次查看(过去 30 天)
RCac = @(~,state) (-k4.*(state.u(1)./K3+state.u(1)).^2+...
k3.*state.u(1)./(KCICR+state.u).*(IP3./(IP3+K2)).^3.*Cas)...
-kon.*state.u(1).*(BT-CaB)+koff.*CaB;
s = @(x, y) RCac;
Fe = wOmega(1) * PhiIPS(:, 1) .* s(ip(1, 1), ip(1, 2)) * areaOfElement + ...
wOmega(2) * PhiIPS(:, 2) .* s(ip(2, 1), ip(2, 2)) * areaOfElement + ...
wOmega(3) * PhiIPS(:, 3) .* s(ip(3, 1), ip(3, 2)) * areaOfElement;
I keep receiving the error message:
'function_handle' 型の入力引数の演算子 '.*' が未定義です。
エラー: BarbeeModel (line 159)
Fe = wOmega(1) * PhiIPS(:, 1) .* s(ip(1, 1), ip(1, 2)) * areaOfElement + ...
in English:
Undefined operator '.*' for input arguments of type 'function_handle'.
Error in
Fe = wOmega(1) * PhiIPS(:, 1) .* s(ip(1, 1), ip(1, 2)) * areaOfElement + ...

采纳的回答

Steven Lord
Steven Lord 2020-1-19
You can't multiply a function handle, which is what s returns. If you intend s to evaluate the function handle RCac, just make it an alias of that function handle.
s = RCac;
Or if you wanted to make it explicit in that line of code that s is a function handle:
s = @(x, y) RCac(x, y);
In either of these cases s(something, somethingElse) returns a number rather than a function handle, and you can multiply a number by another number.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics and Visualization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by