how to plot a time on x-axis and height on y-axis and data with respect to time

1 vue (au cours des 30 derniers jours)
i have a file that is having headerfile data headerfile data.............. in headerfile there is data ht u v w....... i want header seprate and i want to show the plot time(same time which is in text file)on x-axis which is in the headerfile and data u,v,z with respect to height on y-axis. i tried many times ,but time is passing no progress.could any one help me i want to show data is chaning with respect to time please give me program
  2 commentaires
dpb
dpb le 30 Avr 2014
Modifié(e) : dpb le 30 Avr 2014
I thought we did this some time ago at
Did you implement the suggestions there? If so and had a problem, post your code and the precise problem, if any, you experienced.
poshan reddy
poshan reddy le 30 Avr 2014
sir ,the date and time is in the header file it self .i want to plot 0n x-axis time and height on y-axis ;and data(u v w) with respect to it.the u example :suppose data has for u's as (ht u u1 u2 u3 )and u changing with respect to time that is u u1 u2 u3 like that header data

Connectez-vous pour commenter.

Réponse acceptée

dpb
dpb le 30 Avr 2014
Modifié(e) : dpb le 1 Mai 2014
...the date and time is in the header...
Oh, ok...I'm not sure you said that the first go 'round. So, modify the previous to handle that
c=[]; % an empty array to collect data into
dn=[]; % ditto for date/time as Matlab datenum
fmt=repmat('%f',1,4); % format string for the numeric data 4/record
fid=fopen('31oct97.txt','r'); % open the file, return file handle
while ~feof(fid) % begin loop until run out of data in file
l=fgetl(fid); % skip that first line
ERRATA: An extra '%' before the \n in both format strings in original...fixed.
dmy=fscanf(fid,'Date : %2d/%2d/%2d\n').'; % get the d,m,y values
dmy(3)=dmy(3)+1900; % fixup the 2-digit year, put in y,m,d order
hms=fscanf(fid,'Time: %2d:%2d:%2d\n').'; % and h,m,s
dn=[dn;datenum([fliplr(dmy) hms])]; % convert to datenum
% now read a remaining data chunk/concatenate-resize header lines to skip
c=[c;cell2mat(textscan(fid,fmt,187,'headerlines',21))];
fgetl(fid);fgetl(fid); % and get the \n and blank line to repeat
end
I actually debugged the above on your file with the only difference being for brevity I just kept two sets of headers and five lines of data/set. The one difficulty you may run into is that I now see that the data are duplicated for each time at positions I guess(?) so instead of concatenating c as above you may prefer to keep each iteration as a plane in a 3D array to keep each directly associated with the group. Otherwise I guess you'd end up wanting to select into rows by the number/group.
To plot the time series, having dealt with that one way or another,
plot(dn,c(suitable_indices))
datetick('x')
See
doc datenum % and friends
doc datetick
for more details on display time axes.
  4 commentaires
poshan reddy
poshan reddy le 1 Mai 2014
thanks for spending time for me dpr .can you help me how to plot a raw file (.r1)files into timeseries .check this program and say the the errors .i want to first height point vs time axis clear all; close all; clc; %%% file read clear all; close all; clc;
rf=fopen('09JL2008.r2','r')
%%% header read for be=1:5 header= struct('npar',fread(rf,1,'int16'),'nwds',fread(rf,1,'int16'),'nrgb',fread(rf,1,'int16'),'nfft',fread(rf,1,'int16'),'ncoh',fread(rf,1,'int16'),'nicoh',fread(rf,1,'int16'),'ipp',fread(rf,1,'int16'),'pwd',fread(rf,1,'int16'),'cflag',fread(rf,1,'int16'),'nwin',fread(rf,1,'int16'),'w1start',fread(rf,1,'int16'),'w1len',fread(rf,1,'int16'),'w2start',fread(rf,1,'int16'),'w2len',fread(rf,1,'int16'),'year',fread(rf,1,'int16'),'month',fread(rf,1,'int16'),'day',fread(rf,1,'int16'),'hour',fread(rf,1,'int16'),'min',fread(rf,1,'int16'),'sec',fread(rf,1,'int16'),'nbeam',fread(rf,1,'int16'),'beam',fread(rf,1,'int16'),'scan',fread(rf,1,'int16'),'attn',fread(rf,1,'int16'),'noise',fread(rf,1,'int16'),'nrej',fread(rf,1,'int16'),'pthld',fread(rf,1,'int16'),'txpower',fread(rf,1,'int16'),'windfn',fread(rf,1,'int16'),'nomit',fread(rf,1,'int16'),'dtype',fread(rf,1,'int16'),'ver',fread(rf,1,'int16'),'gwind',fread(rf,1,'float'),'gwdir',fread(rf,1,'float'),'temp',fread(rf,1,'float'),'humid',fread(rf,1,'float'),'comments',fread(rf,48,'char'));
%%%data read
nrgb=150;nfft=512;
for rb=1:nrgb
for nft=1:nfft
datI(rb,nft)=fread(rf,1,'float32');
datQ(rb,nft)=fread(rf,1,'float32');
end
end
end
how can i calculate first rangebin with respect to time
dpb
dpb le 1 Mai 2014
...how to plot a raw file (.r1)files into timeseries...
No klew...where's there a definition of the file format?
I'd suggest this might be a case for
doc memmapfile
however

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time 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