maximum variable size allowed by the program is exceeded

2 vues (au cours des 30 derniers jours)
Hana
Hana le 6 Août 2014
Commenté : Hana le 22 Oct 2014
I get error in finding ME. it should return a single mean value from radar matrix which meets the condition.
inc_file ='inc.tif'
[inc,R] = geotiffread(inc_file);
lc_file ='lc.tif'
[lc,R] = geotiffread(lc_file);
rad_file ='rad.tif'
[rad,R] = geotiffread(rad_file);
[ind_x,ind_y] = find (inc ==30 & lc ==10);
ME = mean(radar (ind_x,ind_y));

Réponse acceptée

Chris Turnes
Chris Turnes le 6 Août 2014
Without having access to the TIF file that this code is loading, it is difficult to say for sure, but it seems as if the error is being generated because of how radar is being indexed. When using two output arguments with find, you are storing the column and row indices of the elements satisfying the conditions inc == 30 && lc == 10. Assuming that there are n total results from find, both ind_x and ind_y will be of length n.
However, since these are two vectors that are being used to access the elements of radar, the returned result will be an n x n matrix rather than a vector of length n (for more information, see this article on matrix indexing). This is probably why you are receiving an error about exceeding the maximum variable size.
To illustrate the difference, compare the following:
>> A = [1; 0; 0]*[1, 1, 1]
A =
1 1 1
0 0 0
0 0 0
>> [i,j]=find(A); A(i,j)
ans =
1 1 1
1 1 1
1 1 1
>> k=find(A); A(k)
ans =
1
1
1
This aside, since it seems that you simply want to compute the mean of certain elements satisfying some logical criteria, you probably do not have to call find at all, but can instead use logical indexing. Specifically, try
>> ME = mean(radar(inc == 30 && lc == 10));
and see if that gives you the result you expect.
  2 commentaires
Hana
Hana le 6 Août 2014
Thanks Chris, ME = mean(radar(inc == 30 && lc == 10)); worked well.
Hana
Hana le 22 Oct 2014
Hello Chris,
What if I have 4 differenet images of radar(radar1,radar2,radar3,radar4) and 4 images of inc which covers the pixels of each radar image. I want to calculate mean for all the 4 images at once. ME = mean(radar(inc == 30 && lc == 10)) calculates the mean of radar pixels which mmeet the condition for only one images. How can I calculate mean for all the images?
Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Modify Image Colors dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by