フィルターのクリア

How to get myBinomTest.m to work with array input, not just scalar

1 回表示 (過去 30 日間)
Madeleine P.
Madeleine P. 2012 年 8 月 8 日
Hi,
I am trying to implement a script (myBinomTest.m) within a script which I've written, for a lat/lon grid. I can execute myBinomTest.m at the command prompt (i.e. I type in the inputs (for 1 grid cell) and get a sensible-looking output. However when I type in the input which are arrays (for 91x144 gridcells) I get NaNs as output (disp(pout)). I've tried using do loops and executing the script for each gridcell at the command prompt, but still get the same result. The myBinomTest.m does say that the inputs can be scalars or arrays but it doesn't seem to work with arrays...unless I'm doing something wrong. Can anyone suggest a way I might get this script to work with arrays, not just scalar inputs?
Thanks Mad.P
My commands I'm using:
s_sim2 = ncread('droughtcalc_sim2.nc','nmth_sim2');
n_sim2 = ncread('droughtcalc_sim2.nc','totmth_sim2');
p_sim2 = ncread('droughtcalc_sim2.nc','pctprob_sim1');
lon = ncread('droughtcalc_sim2.nc','lon');
lat = ncread('droughtcalc_sim2.nc','lat');
for i=1:144
for j=1:91
pout=myBinomTest(s_sim2,n_sim2,p_sim2,'Greater');
end
end
disp(pout)

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 8 月 8 日
Possibly
pout(i,j) = myBinomTest(s_sim2(i,j), n_sim2(i,j), p_sim2(i,j), 'Greater');
  1 件のコメント
Madeleine P.
Madeleine P. 2012 年 8 月 9 日
Actually the problem was my bad - thanks for your help though :-)

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

カテゴリ

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