Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
feather plot help please?

Subject: feather plot help please?

From: Bettaiyya

Date: 28 May, 2010 00:40:07

Message: 1 of 1

Hi all,
        Here is the code i wrote for feather plot with time series data (u and v) (wind data). When i get the graph after running this code the dates on the x axis is incorrect.

%% Get Data

[fn,pn] = uigetfile('*.data', 'Open the txt file to be read');
file=fullfile(pn,fn);


count=1;

fid3=fopen(fn,'rt');


%%second=0;

while(~feof(fid3))
   in1=fgetl(fid3);
   if(isequal(in1,''))
       break;
   end
   date=sscanf(in1,'%s',1);
   set1 = find(date=='-',1,'first');
   set2 = find(date=='-',1,'last');
   day = str2double(date(1:set1-1));
   month = date(set1+1:set2-1);
   if(month == 'Jan')
       month = 1;
   end
      if(month == 'Feb')
       month = 2;
      end
      if(month == 'Mar')
       month = 3;
      end
      if(month == 'Apr')
       month = 4;
      end
      if(month == 'May')
       month = 5;
      end
      if(month == 'Jun')
       month = 6;
      end
      if(month == 'Jul')
       month = 7;
      end
      if(month == 'Aug')
       month = 8;
      end
      if(month == 'Sep')
       month = 9;
      end
         if(month == 'Oct')
       month = 10;
         end
         if(month == 'Nov')
       month = 11;
         end
         if(month == 'Dec')
       month = 12;
   end
   year = str2double(date(set2+1:set2+4));
   
   if(year < 100)
     year=year+2000;
   end
   
   
   time=sscanf(in1,'%*s %s',1);
   loc=find(time==':');
   hour=str2double(time(1:loc-1));
   minute=str2double(time(loc+1:loc+2));
   
   vector_time=[year month day hour minute second];
   field.value1(count)=sscanf(in1,'%*s %*s %f',1);
   field.value2(count)=sscanf(in1,'%*s %*s %*f %f',1);
   field.value3(count)=sscanf(in1,'%*s %*s %*f %*f %f',1);
   field.value4(count)=sscanf(in1,'%*s %*s %*f %*f %*f %f',1);
   field.value5(count)=sscanf(in1,'%*s %*s %*f %*f %*f %*f %f',1);
   temp=datestr(vector_time);
   field.time(count)=datenum(temp);
   count=count+1;
end


%% Feather plot

axis([min(field.time(:)) max(field.time(:)) -10 10]);
feather(field.value4(:), field.value5(:));
datetick('x',2,'keepticks');
hold('on');

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us