How to convert all data from text file into a single column?

I am trying to analyze an earthquake signal. For which, I need to plot the acceleration time history. I have obtained earthquake data in the excel sheet as attached in the excel file. The first eight data in a row are the data for increasing time. Next acceleration is the second row. How can I convert the data into a single column so that I can correlate the data with time?

 Accepted Answer

dpb
dpb on 14 Jul 2018
Edited: dpb on 15 Jul 2018
EQ=xlsread('Data.xlsx');
EQ=reshape(EQ(:,1:8).',[],1);
will return the first 8 columns as vector presuming order is by row.
'Tis a very peculiar data storage as described however; what are the last 8 columns--almost all NaN excepting for two very localized areas--
>> d=xlsread('EQData.xlsx');
>> sum(isfinite(d))
ans =
Columns 1 through 10
16361 16362 16371 16369 16358 16354 16354 16354 12 16
Columns 11 through 16
13 12 10 10 10 6
>> is=find(isfinite(d(:,9)));
>> [is d(is)]
ans =
5468 2
5469 0
5470 0
5471 0
5472 14501
5473 0
10956 3
10957 0
10958 0
10959 0
10960 14501
10961 0
>>

2 Comments

Thank you for your time for the answer dpb. But this is not exactly what I mean. I am working out to separate all the data in the excel sheet which are in rows and column in a column.
Well, it does precisely that for the initial description of what the rows/columns are.
"The first eight data in a row are the data for increasing time."
Explain what it is that you do mean, exactly, again.

Sign in to comment.

More Answers (1)

I want the data in the excel file which are in a group of rows and column in a single column.
I would like the excel file with data in the column such that all the data in the rows come first before starting next row. For example, I would like to generate data in the following form.
0.158 -0.304 0.048 0.178 0.097 0.162 0.106 0.155 0.111 0.155 -0.296 -0.381 0.096 0.134 0.144 0.109 and so on for 3rd row and continue...

4 Comments

The data above kept should come in next line after each data.. For example, -0.304 should be in line 2 and 0.048 in line 3 and so on...
That's exactly what the original code does...did you not try it???
>> EQ(1:16)
ans =
0.1580
-0.3040
0.0480
0.1780
0.0970
0.1620
0.1060
0.1550
0.1110
0.1550
-0.2960
-0.3810
0.0960
0.1340
0.1440
0.1090
>>
You're welcome; my wondering what the rest of the data are/were in the initial response may have concealed the result...

Sign in to comment.

Products

Asked:

on 14 Jul 2018

Commented:

dpb
on 16 Jul 2018

Community Treasure Hunt

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

Start Hunting!