フィルターのクリア

Problem plotting sequential data files with headers

3 ビュー (過去 30 日間)
Brantosaurus
Brantosaurus 2023 年 10 月 13 日
移動済み: Dyuman Joshi 2023 年 10 月 15 日
Hello. I managed to read from a sequence of files which contain numeric data in 3 columns of different lengths. I can overlay plot the first and second columns OK. How might i change the code to cope with a 3 line character header in each data file?
Tried importdata which has a header capability to but keep getting plot problems!
Any advice on whether this or another option might be better would be much appreciated. Dave
  2 件のコメント
Walter Roberson
Walter Roberson 2023 年 10 月 13 日
Brantosaurus
Brantosaurus 2023 年 10 月 13 日
Apologies Walter. I missed flagging i'm running 2017a and i believe readmatrix is 2019a :(

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

採用された回答

Walter Roberson
Walter Roberson 2023 年 10 月 13 日
編集済み: Walter Roberson 2023 年 10 月 13 日
readtable with 'HeaderLines' option, after which you can table2array if you want. You might potentially need to use the ReadVariableNames false option.
In the special case that the three header lines all happen to start with % as their first non-blank character, then you can load() the text file and it will skip the lines that start with %
If you were using very large files and readtable() got to be a performance problem, you would fopen the file, and use textscan with a HeaderLines option and then cell2mat the resulting cell array and then fclose
  1 件のコメント
Brantosaurus
Brantosaurus 2023 年 10 月 15 日
移動済み: Dyuman Joshi 2023 年 10 月 15 日
Partial sucess with readtable. I couldn't find reference to use of 'HeaderLines' option, only 'NumHeaderLines',3 as argument in detectImportOptions. However it dosesn't have desired effect and script seems to work without either!
I forgot to mention files have a footer which i'd like to completely ignore (like the header). Footer begins with a row of asterisks followed by an unknown number of numeric lines. Tried 'omitrow' but it only omits the asterisks!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by