フィルターのクリア

Unable to plot. Problem with this error "Conversion to double from function_handle is not possible."

1 回表示 (過去 30 日間)
jayash
jayash 2015 年 2 月 16 日
回答済み: Adam 2015 年 2 月 16 日
function f=snm(~)
eq11= @(q1)(2*(1 - cos(2*pi*q1)));
hq1= @(q1,U,n0)((eq11)^2 + 2*U*n0*(eq11))^(1/2);
ha1= @(q1,U,n0)(((eq11) + (U*n0))/hq1) - 1;
f= @(U,n0)(n0 + 5/10*integral(@(q1)ha1,-0.5, 0.5));
a=@(U)fsolve(f-0.5,0.1);
plot(a,0,20);
I want to plot between "a" and "U", but unable to plot due to this error "Conversion to double from function_handle is not possible." . Could anyone help me out with this problem?

回答 (1 件)

Adam
Adam 2015 年 2 月 16 日
You are attempting to plot a function handle.
The plot function expects data, not a function to evaluate.
Your definition of 'a' takes 'U' as a parameter but then ignores it. Also the syntax of
fsolve(f-0.5,0.1);
does not look correct. I don't have access to the fsolve function, but I assume it should be more like:
fsolve( f, -0.5, 0.1 )
if you are using -0.5 to 1 as your limits. Or rather, I assume you want U to be involved in there somewhere otherwise why pass it as an argument to your 'a' function?

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by