Cell to data column

2 ビュー (過去 30 日間)
Saurabh Srivastava
Saurabh Srivastava 2021 年 2 月 23 日
コメント済み: Saurabh Srivastava 2021 年 2 月 24 日
I have data which is in cell. I want to convert them into table like we do in excel text2column. Hereby, I am attaching a screenshot of the data. I want entire cell array in tabulated form.
  2 件のコメント
Ajiket Patil
Ajiket Patil 2021 年 2 月 23 日
Try this
tbl = rows2vars(data);
Saurabh Srivastava
Saurabh Srivastava 2021 年 2 月 24 日
tried but didn't worked

サインインしてコメントする。

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 23 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 23 日
Try with cell2table
Note that the single coulmn cell data having numeric and non numeric data types. If this is not resolved, please attach a sample data file.
  3 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 24 日
Please share the sample data (not screenshot), and can you show us code what you have tried with table?
Saurabh Srivastava
Saurabh Srivastava 2021 年 2 月 24 日
Hi Kalyan,
Actually I am reading SINEX file. I am sharing the sample data file and corresponding code. If you can sugeest me some better way to read the data, it will be a great help.
Here is the code and file.
% Reading sinex file
fname = 'sampleFile.txt';
fid = fopen(fname)
if fid == -1
disp(['Couldn''t find the file: ', fname])
error('File does not exist')
end
%%
% Finding the breaking point in data file from where I need to read and
% seperate the data.
tline = fgetl(fid);
lineCounter = 0; % Number of linee readed in data file
patternCounter = 0; % Counting that how many time certain pattern comes in data file
patArray = []; % At what line the patter comes, this will hel in seperating different data
while ischar(tline)
% disp(tline)
lineCounter = lineCounter + 1;
if strcmp(tline, '*-------------------------------------------------------------------------------')
patternCounter = patternCounter+1;
patArray = [patArray; lineCounter];
end
% Read next line
tline = fgetl(fid);
end
fclose(fid);
%%
% Slicing and restoring data in desired format
All = textread(fname,'%s','delimiter', '\n');
dataName = All{patArray(4)+1};
data = All(patArray(4)+3:patArray(5)-2);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by