In Excel divide the single column into three columns

Hi...In an Excel table, I want to divide the single column into three columns containing data from the first column,Select from A3 the three columns Tide Amplitude Phase
buffer=fileread('RasTanura 1980 AllYear._AnalysisLog.txt');
data= textscan(buffer, '%s %*f %f %f %f %f %f %f','delimiter','#');
data= [data{1},num2cell([data{2:end}])];
xlswrite('RasTanura 1980 AllYear.xlsx',data);

2 Comments

Attach a short section of the original input file -- looks like should be able to just read it directly if you skip the three header lines. If you want to keep the three data values shown above, I don't understand why you would have written the format string you did???
Converted file txt to xls by code >>now i want Divide the column into three columns containing the (Tide, Amplitude, Phase) and divide columns into four at the row A34 containing (JDay(LST),Observed, Predicted, Residual) datas.
Please help me .. to find a solution

Sign in to comment.

 Accepted Answer

[~, txt] = xlsread('file1.xls');
TAP_cell = regexp(txt(4:29), '(?<Tide>\S+)\s+(?<Amplitude>\S+)\s+(?<Phase>\S+)', 'names', 'once');
TAP = vertcat(TAP_cell{:});
Tides = {TAP.Tide};
Amplitudes = str2double({TAP.Amplitude});
Phases = str2double({TAP.Phase});
JOPR_cells = regexp(txt(35:end), '\s+', 'split');
JOPR_cell = vertcat(JOPR_cells{:});
JOPR = str2double(JOPR_cell);
JDay_LSTs = JOPR(:,1);
Observeds = JOPR(:,2);
Predicteds = JOPR(:,3);
Residuals = JOPR(:,4);

6 Comments

how can i convert cell (Tides) to double..
i want sort one table content T1+T2.. withe write Text=char(d,d2)
[~, txt] = xlsread('file1.xls');
ch1=txt(1:2);ch2=txt(31:33);d=char(ch1);d2=char(ch2);
Text=char(d,d2);
TAP_cell = regexp(txt(4:30), '(?<Tide>\S+)\s+(?<Amplitude>\S+)\s+(?<Phase>\S+)', 'names', 'once');
TAP = vertcat(TAP_cell{:});
Tides = {TAP.Tide};Tides=Tides';
Tides=(cellfun(@str2double, Tides)) ;
Amplitudes = str2double({TAP.Amplitude});Amplitudes=Amplitudes';
Phases = str2double({TAP.Phase});Phases=Phases';
JOPR_cells = regexp(txt(35:end),'\s+', 'split');
JOPR_cell = vertcat(JOPR_cells{:});
JOPR = str2double(JOPR_cell);
JDay_LSTs = JOPR(:,1);
Observeds = JOPR(:,2);
Predicteds = JOPR(:,3);
Residuals = JOPR(:,4);
T1=[Amplitudes,Phases];
T2=[ JDay_LSTs,Observeds,Predicteds,Residuals];
A = array2table(T1, 'VariableNames', {'Amplitude','Phase'});
B = array2table(T2, 'VariableNames', {'JDay_LSTs','Observeds','Predicteds','Residuals'});
writetable(A,'tabel3.xls')
writetable(B,'tabel4.xls')
%N = vertcat(A,B);
Tides are in the file as text. What should be the corresponding double?
how i can write T1=[Tides,Amplitudes,Phases]; and sort one table content T1+T2.. withe write Text=char(d,d2)
Remove the
Tides=(cellfun(@str2double, Tides)) ;
and use
T1 = cell2table( [Tides(:), num2cell(Amplitudes(:)), num2cell(Phases(:))], 'VariableNames', {'Tide', 'Amplitude', 'Phase'});
The problem is in trying to convert the Tide to numeric, since it is text.
  • | | | | Thank you again||||*

Sign in to comment.

More Answers (0)

Categories

Find more on Oceanography and Hydrology in Help Center and File Exchange

Tags

Asked:

on 23 Dec 2017

Commented:

on 26 Dec 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!