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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:16:42+00:00 2026-05-24T22:16:42+00:00

I have a situation in which a large amount of data output from Matlab

  • 0

I have a situation in which a large amount of data output from Matlab programs needs to be stored in a specific location that can vary from machine to machine. What I’d like to have is a global variable that is set at startup for each machine. This variable could then be used by the various programs in order to determine the directory to store the output. Note the approach will need to be platform independent as there a potentially 3 operating systems that will run these scripts.

One approach I considered is using setenv:

setenv('DATDIR',fullfile(path,to,dir));

Then the script/function could query this variable using:

savedir = getenv('DATDIR');

In this case the variable is unaffected by clear inside the Matlab environment.

Another approach I thought to use is simply creating a function (like matlabroot), which is on the path and simply returns a string to which the data directory path is assigned.

function path = datroot()
    path = fullfile(path,to,dir);
end

Finally, to my question: Is there another way to achieve the same result? If Matlab has it’s own environment variables, I’d rather use those instead of functions or system-level variables. Is this possible?

  • 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-05-24T22:16:43+00:00Added an answer on May 24, 2026 at 10:16 pm

    Use the getpref/setpref/ispref/addpref/rmpref set of functions. According to the documentation:

    Preference values are persistent and maintain their values between
    MATLAB sessions. Where they are stored is system dependent.

    This is like .ini or Java .properties files, but instead uses MAT-files to persist the values (which can be of any MATLAB type). On my Windows machine, the file used is stored as:

    %APPDATA%\MathWorks\MATLAB\R2010b\matlabprefs.mat
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that sometimes will utilize a large amount of data. The
I have question regarding the storage of large amount of data. The situation is
I have situation in which I read a record from a database. And if
I have a situation in which I need to convert a text data into
I have a situation where there is a corrupt WAV file from which I'm
We have developed a large data migration from one DB schema to the other.
I have an application that starts by loading a large pickled trie (173M) from
I have a situation in which a managed DLL calls some unmanaged DLL. I
I have a situation in which user can single tap a control, which show
I have a situation in which the ideal relationship, I believe, would involve Value

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.