Converting .sb(.txt) file to excel file

2 ビュー (過去 30 日間)
Arnab Paul
Arnab Paul 2023 年 2 月 6 日
回答済み: Smit 2023 年 2 月 7 日
I have this code below which suppose to convert .sb extension file to excel file. but it is showing error as
Error using fieldnames
Invalid input argument of type 'cell'. Input must be a structure or a Java or COM object.
Error in sb2exl (line 4)
fields = fieldnames(data);
For the convenience of attaching the file, I have converted it to .txt file
data = readsb('6bbb44bb68_archive01.sb');
%preprocess the datato reformat into table format
fields = fieldnames(data);
for i = 1:numel(fields)
field = fields{i};
T.(field) = data.(field)(:);
end
writetable(T, '6bbb44bb68_archive01.xlsx');
Any help is appriciated.

採用された回答

Smit
Smit 2023 年 2 月 7 日
Hi Arnab,
I understand you are trying to convert a “.sb” file to an Excel file. You are using the “readsb” function to read the data from the file and are getting an error while pre-processing the data from the “readsb” function.
The error suggests that the data read from “readsb” is in a cell format, but the function “fieldnames” expects a structure, Java, or COM object input.
The “readsb” function can take other inputs which specify whether to return the data as a structure.
You can get the “.sb” file data in a struct using the following command
readsb('6bbb44bb68_archive01.sb', 'MakeStructure', 1);
You can refer this link for more information on the “readsb” function.
This should resolve the error. However, you might need to use the “struct2table” function while writing the Excel file.
You can do so in the following manner
writetable(struct2table(T), '6bbb44bb68_archive01.xlsx');

その他の回答 (0 件)

カテゴリ

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