FZERO cannot continue because user-supplied function_handle, A and B must be floating-point scalars.
12 ビュー (過去 30 日間)
古いコメントを表示
My code is:
p=0.51:0.001:1.013;
fun1 = @(x) x.^2.*exp(-x)./(1-exp(-10));
fun2 = @(x,u) fzero(@(y) 2.*u.*y.*(20-p-x+y).^0.5-0.5,[0,10]).^2.*exp(-x)./(1-exp(-10));
fun3 = @(u) integral(@(x) fun1(x),0,0.5./(20-p)^0.5./(2.*u))+integral(@(x) fun2(x,u),0.5./(20-p)^0.5./(2.*u),10,'arrayvalued', true);
fun11 = @(x) x.*exp(-x)./(1-exp(-10));
fun21 = @(x,u) fzero(@(y) 2.*u.*y.*(20-p-x+y).^0.5-0.5,[0,10]).*exp(-x)./(1-exp(-10));
fun31 = @(u) integral(@(x) fun11(x),0,0.5./(20-p)^0.5./(2.*u))+integral(@(x) fun21(x,u),0.5./(20-p)^0.5./(2.*u),10,'arrayvalued', true);
fun4 = @(x,u) (20-x+fzero(@(y) 2.*u.*y.*(20-p-x+y).^0.5-0.5,[0,10])-p)^0.5.*exp(-x)./(1-exp(-10));
fun44= @(u) integral(@(x) (20-p).^0.5.*exp(-x)./(1-exp(-10)),0,0.5./(20-p)^0.5./(2.*u))+integral(@(x) fun4(x,u),0.5./(20-p)^0.5./(2.*u),10,'arrayvalued', true);
fun51 =@(p) p - feval(fun31,fzero(@(u) fun3(u)-0.9973,[0.02,1]));
fun52 =@(p) feval(fun44,fzero(@(u) fun3(u)-0.9973,[0.02,1])) - integral(@(x) (20-x).^0.5.*exp(-x)./(1-exp(-10)),0,10);
plot3(p,fun51(p),fun52(p))
format long
Here is the error I get:
FZERO cannot continue because user-supplied function_handle ==> @(u)fun3(u)-0.9973 failed with the error below.
One argument must be a square matrix and the other must be a scalar. Use POWER (.^) for elementwise power.
I am sorry that my function is a little bit messy. But I am worried about that you may miss some information if I simplify it. Any help is appreciated, thanks!
1 件のコメント
Walter Roberson
2019 年 1 月 10 日
Your code is confusing the parameter named p with the p you set to the numeric vector.
採用された回答
Torsten
2019 年 1 月 10 日
Make a loop over the elements of p.
"fzero" cannot determine zeros of vector-valued functions (like in fzero(@(y) 2.*u.*y.*(20-p-x+y).^0.5-0.5,[0,10]) in fun2).
4 件のコメント
Walter Roberson
2019 年 1 月 10 日
Just accept Torsten's answer, since he provided the key about looping over p.
その他の回答 (2 件)
Andrea
2023 年 3 月 31 日
AUXILIOOO COMO RESUELVO ESTO?
Error using fzero>localFirstFcnEvalError FZERO cannot continue because user-supplied function_handle ==> @(t)((R*t)/(Vmol-b))-((psi*((R^2*Tc^2*(((1+(0.48+(1.574*w)-(0.176*w^2))*(1-sqrt(t/Tc))))^2))/Pc))/((Vmol+(epsilon*b))*(V+(sigma*b))))-P failed with the error below. Error: File: V.m Line: 49 Column: 9 Using 'V' as both the name of a variable and the name of a script is not supported.
1 件のコメント
Torsten
2023 年 3 月 31 日
編集済み: Torsten
2023 年 3 月 31 日
Using 'V' as both the name of a variable and the name of a script is not supported.
El mensaje de error es obvio. Cambie el nombre de la variable "V" en su código o asigne a su secuencia de comandos un nombre diferente.
Y dado que el identificador de su función se llamará con vectores para t, debe usar la multiplicación y división por componentes (.* y ./) en lugar de la multiplicación normal en los casos en que sea necesario.
参考
カテゴリ
Help Center および File Exchange で Nonlinear Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!