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 8236249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:04:56+00:00 2026-06-07T19:04:56+00:00

I have a following parameter file in which I want to change values on

  • 0

I have a following parameter file in which I want to change values on left hand side starting with gam.dat till 1 1 1 (against -tail variable, head variable, variogram type) without changing the format of the file.

This parameter file will be called inside the loop such that each iteration of the loop would require changing the values inside this parameter file.

Reading and writing from a file has always been my weak point. Any help on how this can be done easily? Thanks!

                  Parameters
                  **********

START OF PARAMETERS:
gam.dat                         -file with data
1   1                           -   number of variables, column numbers
-1.0e21     1.0e21              -   trimming limits
gam.out                         -file for output
1                               -grid or realization number
100   1.0   1.0                 -nx, xmn, xsiz
100   1.0   1.0                 -ny, ymn, ysiz
 20   1.0   1.0                 -nz, zmn, zsiz
4  30                           -number of directions, number of h
1  0  1                         -ixd(1),iyd(1),izd(1)
1  0  2                         -ixd(2),iyd(2),izd(2)
1  0  3                         -ixd(3),iyd(3),izd(3)
1  1  1                         -ixd(4),iyd(4),izd(4)
1                               -standardize sill? (0=no, 1=yes)
1                               -number of gamma
1   1   1                       -tail variable, head variable, gamma type
  • 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-07T19:04:58+00:00Added an answer on June 7, 2026 at 7:04 pm

    Something like this might help. Then again it might not be exactly what you’re looking for.

    fid = fopen(filename as a string);
    n = 1;
    textline = [];
    while( ~feof(fid) ) // This just runs until the end of the file is reached.
        textline(n) = fgetl(fid)
        // some operations you want to perform?
        // You can also do anything you want to the lines here as you are reading them in.
        // This will read in every line in the file as well.
        n = n + 1;
    end
    
    fwrite(fid, textline);  // This writes to the file and will overwrite what is already there.
    // You always write to a new file if you want to though!
    fclose(fid);
    

    The only reason I am suggesting the use of fgetl here is because it looks like there are specific operations/changes you want to make based on the line or the information in the line. You can also use fread which will do the same thing but you’ll then have to operate on the matrix as a whole after it’s built rather than making any modifications to it while reading the data in and building the matrix.

    Hope that helps!

    More complete example based on the comments below.

    fid = fopen('gam.txt');
    n = 1;
    textline = {};
    while( ~feof(fid) ) % This just runs until the end of the file is reached.
    textline(n,1) = {fgetl(fid)}
    % some operations you want to perform?
    % You can also do anything you want to the lines here as you are reading them in.
    % This will read in every line in the file as well.
    
    if ( n == 5 )  % This is just an operation that will adjust line number 5.
        temp = cell2mat(textline(n));
        textline(n,1) = {['newfile.name', temp(regexp(temp, '\s', 'once'):end)]};
    end
    
    n = n + 1;
    end
    fclose(fid)
    
    
    fid = fopen('gam2.txt', 'w') % this file has to already be created.
    for(n = 1:length(textline))
        fwrite(fid, cell2mat(textline(n));
    end
    fclose(fid)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code and i want to pass additional parameter in JSON.getJSONfromURL() method
I have the following code which takes List of boolean as a parameter then
In python I have the following function: def is_a_nice_element(element, parameter): #do something return True
Suppose I have an Oracle 11.2 database containing the following table: TABLE: SURVEY PARAMETER
I have the following code which is fine if I give invalid parameters (though,
I want to show an image on a jasper report. I have the following
I have a model named Entree for which the new action needs a parameter,
I have the following problem compiling a C++ file from a third-party library in
I have following environment: masterpage with a contentPlacholder multiple pages which use this masterpage
I have a small C# program to modify a xml file which is located

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.