Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Madeleine P.
Madeleine P. le 8 Août 2012
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)

Réponses (1)

Walter Roberson
Walter Roberson le 8 Août 2012
Possibly
pout(i,j) = myBinomTest(s_sim2(i,j), n_sim2(i,j), p_sim2(i,j), 'Greater');
  1 commentaire
Madeleine P.
Madeleine P. le 9 Août 2012
Actually the problem was my bad - thanks for your help though :-)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by