how to give input for functions
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
shobi swaminathan
el 28 de En. de 2014
Respondida: shobi swaminathan
el 28 de En. de 2014
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.
0 comentarios
Respuesta aceptada
Mischa Kim
el 28 de En. de 2014
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 comentarios
Mischa Kim
el 28 de En. de 2014
Pi is the x-value you are searching for, FVal is the function value that is minimized at x = Pi.
Más respuestas (1)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!