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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:17:57+00:00 2026-06-12T11:17:57+00:00

Possible Duplicate: How do I retrieve the names of function parameters in matlab? I’m

  • 0

Possible Duplicate:
How do I retrieve the names of function parameters in matlab?

I’m looking for a way to get all the arguments passed to, or expected my function. The args() command seems to be ideal but is only available for procedures. Is there anyway of doing this.

My reason I want to do this is so I can do my checking in fewer lines. ie check all inputs are numeric by writing one check then executing for all args. So if there is a good alternative I’m open to ideas.

Thanks

  • 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-12T11:17:58+00:00Added an answer on June 12, 2026 at 11:17 am

    You can use varargin, as petrichor mentioned. varargin is a cell, so you can easily perform validation of all your parameters in one line using cellfun:

    function c = test(varargin)
    cellfun(@(arg)validateattributes(arg, {'numeric'}, {'integer'}), varargin);
    

    The above code runs validateattributes for all function parameters. On the other hand, if you want named variables, you can still group them into cells and run specific tests as above:

    function c = test(i1, i2, d1, d2)
    
    % validate integer arguments
    cellfun(@(arg)validateattributes(arg, {'numeric'}, {'integer'}), {i1, i2});
    
    % validate double arguments
    cellfun(@(arg)validateattributes(arg, {'double'}, {'positive'}), {d1, d2});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: get all available fonts from google font api How we can retrieve
Possible Duplicate: Retrieve Windows Experience Rating Using .NET, is there a way to programmatically
Possible Duplicate: What is the most accurate way to retrieve a user's correct IP
Possible Duplicate: Best way to get files from a dir filtered by certain extension
Possible Duplicate: Retrieve Table Row Index of Current Row <html> <script> function addValue(a) {
Possible Duplicate: Retrieve column names from java.sql.ResultSet I have query which returns the result
Possible Duplicate: What is the most accurate way to retrieve a user's correct IP
Possible Duplicate: What is a good way to get a list of files from
Possible Duplicate: how to get value when a variable name is passed as a
Possible Duplicate: Fastest way to retrieve a <title> in PHP Suppose there is a

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.