maximum variable size allowed by the program is exceeded
2 views (last 30 days)
Show older comments
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));
0 Comments
Accepted Answer
Chris Turnes
on 6 Aug 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.
More Answers (0)
See Also
Categories
Find more on Detection in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!