Monday, December 8, 2014

iteration limit reached in robustfit matlab

Warning: Iteration limit reached.
> In stats\private\statrobustfit at 76
  In robustfit at 106

So, I tracked down the robustfit function. In MATLAB 2013a, it is located at:
as statrobustfit.
Around line 70 was the iteration limit set to 50. Changed that to 250. So far my data does not seem to get any improvements by this; but it is here if it could be useful.

iter = 0;
iterlim = 250; % modified from 50
wxrank = xrank;    % rank of weighted version of x
while((iter==0) || any(abs(b-b0) > D*max(abs(b),abs(b0))))
   iter = iter+1;
   if (iter>iterlim)

Friday, December 5, 2014

creating csv with header text in matlab

The csvwrite function in matlab does not work well with the text. There is a table feature in the new matlab version. However, here is a quick way to create csv with text header in matlab

csvData = [Elev TPW SkinT SurfacePr dayyes' ProfType Uyear Umo Uhr latitude longitude];

header=['Elev,TPW,SkinT,SurfacePr,dayyes,ProfType, year, mo,HH, latitude,longitude'];
outid = fopen('SeeBor.csv', 'w+');
fprintf(outid, '%s', header);
dlmwrite ('SeeBor.csv',csvData,'roffset',1,'-append')

Thursday, December 4, 2014

Latitude Longitude and Data on Map @matlab

I wanted to have a nice map of the global dataset given the lat/lon and the dataset.
This code is being put here so that it could be used later.
boxmap = 0
% close all

latlim = [-90, 90];
lonlim = [-180, 180];
load coast

if boxmap
    axesm('MapProjection','lambcyln','grid','on', ...
        'MLineLocation',15, 'PLineLocation',15)
    ax = worldmap(latlim, lonlim);
geoshow(lat, long,'Color', 'black' )

for jj = 1:length(cimms)
    [SunRiseSet,Day,Dec,Alt,Azm,Rad] = suncycle( latitude(jj) , longitude(jj) , [Uyear(jj) Umo(jj) Uday(jj)] , 2880 );
    if SunRiseSet(2)<SunRiseSet(1)
        SunRiseSet(2) = SunRiseSet(2)+24;
    if Uhr(jj)>SunRiseSet(1) & Uhr(jj)<SunRiseSet(2)
        plotm(latitude(jj),longitude(jj), jj,'o', 'MarkerEdgeColor','r','MarkerSize',8);
        dayyes(jj) = 1;
        plotm(latitude(jj),longitude(jj), jj,'o', 'MarkerEdgeColor','b','MarkerSize',8);
        dayyes(jj) = 0;
    hold on
    if rem(jj,1000)==0
        textm(latitude(jj),longitude(jj),  sprintf('%.1d', jj), 'color', 'g')