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

  • Home
  • SEARCH
  • 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 6947695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:43:33+00:00 2026-05-27T13:43:33+00:00

I have written a function that takes the names and values of the input

  • 0

I have written a function that takes the names and values of the input variables and writes them to a file. eg.

a = 10;
b = 100;
writevars('file.txt',a,b);

gives me a file file.txt that contains:

\def\a{\num{10}}
\def\b{\num{100}}

It would now like to be able to pass on all variables that are found using the who command. Eg if who returns:

a    b    z

I would like to be able to use writevars as if I called writers('file.txt', a, b, z).

The main problem I have is that writevars makes use of inputname… (temporary variables won’t work e.g. writevars('file.txt', 100) doesn’t work since there is no name to be given in the file).

ANSWER

var_names = who;
for i = 1 : length(var_names)
    evalin('caller',['writevars(''file.txt'', ' char(var_names(i)) ' )']);
end
  • 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-27T13:43:34+00:00Added an answer on May 27, 2026 at 1:43 pm

    You can use EVALIN to run who from within writevars, e.g.

    function writevars(filename,varargin)
    
    %# get a list of variable names in the calling workspace and read their values
    if isempty(varargin)
       listOfVars = evalin('caller','who');
       values = cell(size(listOfVars));
       for i=1:length(listOfVars)
          values{i} = evalin('caller',listOfVars{i});
       end
    else
       %# use inputname to read the variable names into listOfVars
    end
    
    %# --- rest of writevars is here ---
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parser function written in my code-behind file, that takes as input
Im have written a small function that basically takes the currentPosition value as a
I have written a function below that takes a pointer to the front of
I have written a PHP function to take a video embed code that has
I have a function I've written that was initially supposed to take a string
I have written a function that gets a given number of random records from
I have written a function that positions a tooltip just above a textbox. The
I have written a javascript function that uses setInterval to manipulate a string every
I have the view function in django that written like a dispatcher calling other
I have written the following function: it takes in a variable input_name ; The

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.