how to give input for functions

4 ビュー (過去 30 日間)
shobi swaminathan
shobi swaminathan 2014 年 1 月 28 日
回答済み: shobi swaminathan 2014 年 1 月 28 日
function Y = myFunc(P,P0)
N = 2;
Pa = 9;
k = floor((P0*N/Pa));
Y = F(P)+k*F(N*P0-P*k);
function Fp = F(P)
R = 3;
beta = 8;
Fp = 1 - exp(-((2^R-1)./P).^(beta/2));
%Step 2: Minimize it within the bounds:
P0 = 9;
[Pi, FVal] = fminbnd(@(x) myFunc(x,P0),0,7);
getting error: Error using myFunc (line 4)
Not enough input arguments.

採用された回答

Mischa Kim
Mischa Kim 2014 年 1 月 28 日
Hello Shobi, code looks fine. Make sure to save the two functions in one function file (called myFunc.m). Then execute the two final commands in the MATLAB command window:
P0 = 9;
[Pi, FVal] = fminbnd(@(x) myFunc(x,P0),0,7);
  10 件のコメント
shobi swaminathan
shobi swaminathan 2014 年 1 月 28 日
Thanks...we are getting the output....
But this code was taken from this website....
We are getting two values Pi and Fval Which one should we take it as minimum...what does Fval means
Mischa Kim
Mischa Kim 2014 年 1 月 28 日
Pi is the x-value you are searching for, FVal is the function value that is minimized at x = Pi.

サインインしてコメントする。

その他の回答 (1 件)

shobi swaminathan
shobi swaminathan 2014 年 1 月 28 日
Thanks alot.. in the above code the value of P and P0 are fixed.. but in our problem the value of P
and P0 should be as follows
P0 varies from 1 to 10 and
P belongs to P1 such that P1= [0, Pb]∪ ((N*P0)/(k+1)). how to modify the above code to satisfy
these conditions

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by