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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:15:23+00:00 2026-06-11T14:15:23+00:00

I am running a model for predicting water temperatures for a certain location and

  • 0

I am running a model for predicting water temperatures for a certain location and the model requires some initial inputs for the meteorological conditions. The inputs that the user must change are stored in a file with an extension .NML. I would like to access this file (from matlab) and run the model with a range of values for a specific variable. For example, there is one variable called ‘input_slope’ which the user must specify. I would like to run the model with a number of different values for this variable e.g. from 1:100 then run the model (application file) and compare the model outputs to my observed values.

I am really new to this and would like to know how I could start with altering an input file in matlab and then execute the model with these new values?

Thank you for your time.

  • 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-11T14:15:24+00:00Added an answer on June 11, 2026 at 2:15 pm

    If you want to alter an input file in Matlab, I would recommend the C like file IO functions like fopen, fgetl, and friends. Here’s a snippet I modified from the online docs that I use as a pattern often:

    fid = fopen('fgetl.m');
    
    file_data = {};
    tline = fgetl(fid);
    while ischar(tline)
        file_data{end+1} = tline;
        tline = fgetl(fid);
    end
    
    fclose(fid);
    

    Some would complain about not initializing the size of the cell array, file_data, but for now let’s just get up and running. The cell array will contain a string for each line in your file with the newline removed. You can access the string like so:

    str = file_data{1};
    

    Then str is a character array with your data. You can use textscan to get numbers, strings, etc. from the str value.

    If you need to write out data, you could try something like:

    fid = fopen('myOutputFile.txt','w');
    % data is in data and is an array of floating point numbers
    for ii=1:length(data)
       fprintf(fid,'%f\n',data(ii));
    end
    fclose(fid);
    

    Looks like this is an externally executable program so I would recommend using the system command to execute and get the return value from the program. I’m not sure how new you are to all this, so please let me know if this is helpful or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After running a model in fortran (95) I end up with some result arrays
I'm running into an issue with an existing ActiveRecord::Observer model that records various Activities
I am running a MySQL database in rails 2.3. my model associations that I
I have a user model that checks to see if a value has changed
I am writing some simulation code and managed to get my model running as
I am running a unit test on a user model in ruby. I am
I have a rails app (running on version 2.2.2) that has a model called
I have an application running in Heroku. The app has a User model with
Django-admin is pluralizing a model that I have running as a proxy class. The
I'm running a simulation in NetLogo based on Rebellion model, in which some agents

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.