フィルターのクリア

I keep getting x as a single value output instead of an array of 14values..

2 ビュー (過去 30 日間)
Austin
Austin 2015 年 8 月 25 日
回答済み: Jan 2015 年 10 月 27 日
below are my codes: i would like to obtain an array for 14values for my x but i keep getting a single value output for x instead. Can anyone kindly advise on where have i gone wrong here?
a=0.5483 b=0.3941 c=0.9837
wl=200:100:1500 k1=0.5543 k2=0.4212 k3=0.4531
x=((1+((a.*(wl).^2)/(((wl).^2)-((k1)^2)))+((b.*(wl).^2)/(((wl).^2)-((k2)^2)))+(c.*((wl).^2)/(((wl).^2)-((k3)^2))))).^0.5

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 8 月 25 日
Replace / by ./
x=((1+((a.*(wl).^2)./(((wl).^2)-((k1)^2)))+((b.*(wl).^2)./(((wl).^2)-((k2)^2)))+(c.*((wl).^2)./(((wl).^2)-((k3)^2))))).^0.5

その他の回答 (1 件)

Jan
Jan 2015 年 10 月 27 日
By the way: An optical simplification of the code can decrease the debug time:
wl_2 = wl .^ 2;
x = sqrt(1 + (a .* wl_2 ./ (wl_2 - k1^2)) + ...
(b .* wl_2 ./ (wl_2 - k2^2)) + ...
(c .* wl_2 ./ (wl_2 - k3^2)))
Just some spaces, removing unneeded parenthesis and a temporary variable.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by