Help me with this code
3 views (last 30 days)
Show older comments
I wrote a code to pick a parameter from the data set.
The code can only read line and extract parameter desired from the dataset. However, I want the code to be able to use the timestamp so that the code can be useful for an incomplete dataset. Full dataset is attached.
- An example of the data is: *CPNFC 2006/01/02 00:00:00 fmin =[---- ] foE =[---- ] h'E =[---- ] foE2 =[---- ] h'E2 =[---- ] fzE =[---- ] fminE =[---- ] foE3 =[---- ] h'E3 =[---- ] fminEs =[---- ] foEs =[ E] h'Es =[ E] TYPES =[----- ] fbEs =[---- ] foEs-type2=[---- ] h'Es-type2=[---- ] fbEs-type2=[---- ] foEs-type3=[---- ] h'Es-type3=[---- ] fbEs-type3=[---- ] fxEs =[---- ] fEs =[---- ] fm2E =[---- ] fm3E =[---- ] fminF =[---- ] foF0.5 =[---- ] foF1 =[---- ] fxF1 =[---- ] M(3000)F1 =[---- ] h'F0.5 =[---- ] h'F =[ 230 ] foF1.5 =[---- ] h'F2 =[ ] h'F1.5 =[---- ] foF2 =[ 455 ] fxF2 =[---- ] M(3000)F2 =[ 146 ] foI =[---- ] fxI =[---- ] dfs1 =[---- ] dfs2 =[---- ] dfs3 =[---- ] dfs4 =[---- ] TYPEF =[----- ] fxI1 =[---- ] fxI2 =[---- ] fzF2 =[---- ] h'I =[---- ] hdF2 =[---- ] hpF2 =[---- ] hmF2 =[---- ] h'ox =[---- ] Zm =[---- ] ypF2 =[---- ] h'F1 =[---- ] Zd =[---- ] foI1 =[---- ] foI2 =[---- ] f1MUF =[---- ] f2MUF =[---- ]
Filename='CPNFC20060102.txt'; % runs fine
Data = importdata(Filename);
%
%Selecting cell Line every hour
for i=1:24;
for j=1;
FreqLine{j,i}=Data{(i-1)*64+10,1};
end
end
%
FreqLine=FreqLine';
% Spliting the cell to get character
for i=1:24
for j=1;
FreqCharLn(i,:)=FreqLine{i,j};
end
end
% Picking the parameter value of interest(foF2) from the dataset
for i=1:24
FreqStrg(i,:)=FreqCharLn(i,57:59);
end
% Convert string to number
FreqChar(FreqStrg == ' ')='0' % replace empty spaces with zero
FreQ=str2num(FreqStrg) % Covert string to number
FreQ(FreQ==000)=nan; % Parameter is obatined
Answers (0)
See Also
Categories
Find more on String Parsing 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!