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