フィルターのクリア

Getting errors specifying an anonymous function, integrating and getting points from it.

1 回表示 (過去 30 日間)
I want solve the follwing equation and get the values of n0 for different values of U ie. U=1:1:20;
the above equation has singularity at q=0, therefore I used 'quad' instead of 'integral'. Please let me know if this is correct or not?
function cv = test2(n0,U)
eq = @(q,n0,U) 2*(1 - cos(2*pi*q));
hq = @(q,n0,U) ((eq)^2 + 2*U*n0*(eq))^(1/2);
y = @(q,n0,U) (((eq) + (U*n0))/hq) - 1;
a = -0.5;
b = 0.5;
v = @(q) quad(y,a,b);
cv = n0+(0.5*v)-1;
end
but I get the following errors
Undefined function 'mtimes' for input arguments of type 'function_handle'.
Error in test2 (line 8)
cv = n0+(0.5*v)-1;
Anybody please help me out. Thanks

採用された回答

Star Strider
Star Strider 2015 年 2 月 23 日
You need to use the argument lists in functions you reference within another function. I can’t run your code, so try this:
hq = @(q,n0,U) ((eq(q,n0,U)).^2 + 2*U.*n0.*(eq(q,n0,U))).^(1/2);
y = @(q,n0,U) (((eq(q,n0,U)) + (U*n0))./hq(q,n0,U)) - 1;
and:
v = quad(@(q) y(q,n0,U), a, b);
Note: Untested code.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by