"Undefined function" error when using multiple anonymous functions

I'm writing a script that defines several anonymous functions, many of which reference other functions. However, one particular function always returns an "undefined function" for one of its nested functions each time I call it.
b = 3.048; % wing span, meters
B = .2286; % ball diameter, m
t = .0762; % extra fuselage material, m
a_w = @(AR,f_w)((b^2)./AR)-(c(AR).*f_w); % planform area (fuse accounted for)
c = @(AR) (10*b)./(9*AR); % chord length
>> c(5:12)
ans =
0.6773 0.5644 0.4838 0.4233 0.3763 0.3387 0.3079 0.2822
>> a_w(5:12,B+t)
Undefined function or variable 'c'.
Error in LiveEditorEvaluationHelperESectionEval>@(AR,f_w)((b^2)./AR)-(c(AR).*f_w)
As you can see above, if I call c by itself, it functions normally. When I call a_w, however, it returns an undefined function error for c.
I feel like I've got to be missing something obvious. Any help would be greatly appreciated!

2 件のコメント

madhan ravi
madhan ravi 2019 年 9 月 14 日
Values of B , t and b??
Joseph Skelley
Joseph Skelley 2019 年 9 月 14 日
Updated to include these values.

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

 採用された回答

madhan ravi
madhan ravi 2019 年 9 月 14 日
編集済み: madhan ravi 2019 年 9 月 14 日

1 投票

Define c anonymous function before a_w and everything will be fine.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Multidimensional Arrays についてさらに検索

製品

リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by