Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:59:08+00:00 2026-06-10T18:59:08+00:00

I have an input text file which is well structured: START_PARAMETERS C:\Users\admin\Desktop\Bladed_wind_generator\_wind C:\Users\admin\Desktop\Bladed_wind_generator\reference_v_4_2.$PJ END_PARAMETERS

  • 0

I have an input text file which is well structured:

START_PARAMETERS
C:\Users\admin\Desktop\Bladed_wind_generator\_wind
C:\Users\admin\Desktop\Bladed_wind_generator\reference_v_4_2.$PJ
END_PARAMETERS
---------------------------------------------------------------------------
START_DLC1-2
4 6 8 10 12 14 16 18 20 22 24 26 28 29
6
8192
600
END_DLC1-2
---------------------------------------------------------------------------
START_DLC6-1
44.8
30
8192
600
END_DLC6-1
---------------------------------------------------------------------------
START_DLC6-4
3 31 33 35
6
8192
600
END_DLC6-4
---------------------------------------------------------------------------
START_DLC7-2
2 4 6 8 10 12 14 16 18 20 22 24 
6
8192
600
END_DLC7-2
---------------------------------------------------------------------------

At the moment I read it this way:

clc,clear all,close all

f = fopen('inp.txt','rt');  % Read Input File
C = textscan(f, '%s', 'Delimiter', '\r\n');
C = C{1}; % Store Input File in a Cell
fclose(f);

Then, by means of regexp I read every occurrence of (START_DLC/END_DLC) block:

startIndx = regexp(C,'START_DLC','match');
endIndx = regexp(C,'END_DLC','match');

The aim is to store the content of the text between each START_DLC/END_DLC block in a structured cell(supposed to be called store_DLCs). The result has to be(e.g. DLC1-2):

DLC1-2
4 6 8 10 12 14 16 18 20 22 24 26 28 29
6
8192
600

and so on until DLC7-2.

Would you mind to give me some hints how to proceed?

I thank you all in advance.

BR,
Francesco

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:59:10+00:00Added an answer on June 10, 2026 at 6:59 pm

    Your code so far is okay. One thing though, I’d slightly alter your computation of startIndx and endIndx to the following:

    startIndx = find(~cellfun(@isempty, regexp(C, 'START_DLC', 'match')));
    endIndx = find(~cellfun(@isempty, regexp(C, 'END_DLC', 'match')));
    

    so that you would get actual indices (I’ve transposed them here for visual convenience), like so:

    startIndx =
    
         6    13    20    27
    
    
    endIndx =
    
        11    18    25    32
    

    I’d also add an assertion to check the integrity of the input:

    assert(all(size(startIndx) == size(endIndx)))
    

    Now, with all the indices computed as above, you can proceed to extract the data into cells:

    extract_dlc = @(n)({C{startIndx(n):endIndx(n) - 1}});
    store_DLCs = arrayfun(extract_dlc, 1:numel(startIndx), 'UniformOutput', false)
    

    And to “fix” the names (which are first entries) of each cell, you can do:

    fix_dlc_name = @(x){strrep(x{1}, 'START_', ''), x{2:end}};
    store_DLCs = cellfun(fix_dlc_name, store_DLCs,  'UniformOutput', false);
    

    This code applied on your example input would yield a 1-by-4 cell array of cells:

    store_DLCs =
    
        {'DLC1-2', '4 6 8 10 12 14 16 18 20 22 24 26 28 29', '6', '8192', '600'}  
        {'DLC6-1', '44.8', '30', '8192', '600'}   
        {'DLC6-4', '3 31 33 35', '6', '8192', '600'}   
        {'DLC7-2', '2 4 6 8 10 12 14 16 18 20 22 24', '6', '8192', '600'}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linux utility that parses structured input ( a text file ),
I have a text file,which I use to input information into my application.The problem
I have a text file input which contains data as below. How can I
I have a text file (c:\input.txt) which has: 2.0 4.0 8.0 16.0 32.0 64.0
I have an input text file, which consists of few columns namely TransactionID ,
Input: I have a LaTeX file, with plain text & math formulas. Desired output:
I have two input text boxes which are decimal. The sum of the two
I have a text file which was created using some Microsoft reporting tool. The
I have a text file which is read in. It has delimeters which are
I have a pipe delimited text file as shown below, which I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.