For the case of t being equal to ten, it was found that the line of code that was generating the Subscripted assignment dimension mismatch error was
The variables F1, lon, lat, and weight were all empty due to the all elements in the s(t,:,:) matrix being set to NaN.
A solution was to address this in the code as follows - if it was found that the a matrix was empty (after the removal of NaNs) then do nothing (or set the output to be all zeros) and just continue with the next iteration of the for loop
a=squeeze(s(t,:,:));
a=a(:);
bad1=find(isnan(a)==1);
a(bad1) = [];
if isempty(a)
AM(t,:,:) = 0;
else
lon=REF_lon(:);
lon(bad1)=[];
lat=REF_lat(:);
lat(bad1)=[];
w = weight(:);
w(bad1)=[];
F1=TriScatteredInterp(lon,lat,a,'natural');
W1=TriScatteredInterp(lon,lat,w,'natural');
a_m=F1(x,y);
AM(t,:,:)=a_m;
W=W1(x,y);
Wrep(t,:,:)=W;
end
Best Answer