Missing input in the argument

2 ビュー (過去 30 日間)
Mathew
Mathew 2025 年 2 月 15 日
回答済み: Walter Roberson 2025 年 2 月 15 日
clear all; close all;
a=0.35; M=1; r0=0; r1=0; p=0.5; d=0.5; Z=100;
K=@(t,p,Z,d,r1) (p*Z-d-exp(-t))*r1;
P = 0:0.1:10;
for i = 1:numel(P)
V(i) = r0 + ((1-a)./M)*integral(K,0,P(i))+ (a./M)*integral(K,0,P(i));
r1=v(i);
end
Not enough input arguments.

Error in solution>@(t,p,Z,d,r1)(p*Z-d-exp(-t))*r1 (line 3)
K=@(t,p,Z,d,r1) (p*Z-d-exp(-t))*r1;

Error in integralCalc>midpArea (line 416)
fx = f(x);

Error in integralCalc (line 66)
q = midpArea(FUN,A,B,opstruct);

Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
plot(P,V),grid

採用された回答

Walter Roberson
Walter Roberson 2025 年 2 月 15 日
K=@(t,p,Z,d,r1) (p*Z-d-exp(-t))*r1;
K is defined needing 5 input parameters.
V(i) = r0 + ((1-a)./M)*integral(K,0,P(i))+ (a./M)*integral(K,0,P(i));
integral() calls the given function with exactly one input parameter. p, Z, d, r1 are all undefined as far as K is concerned.
If you had defined
K=@(t) (p*Z-d-exp(-t))*r1;
then the existing numeric values of p, Z, d, and r1 would be "captured" by the function handles, and everything would be fine.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by