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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:28:16+00:00 2026-05-26T11:28:16+00:00

How to test/validate a variable is a function handle in matlab ? it may

  • 0

How to test/validate a variable is a function handle in matlab ?

it may be something like:

f=@(x)x+1
isFunctionHandle(f)

the is* build-in functions seems not support these kind testing? anyone know? many 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-05-26T11:28:17+00:00Added an answer on May 26, 2026 at 11:28 am

    The right way is indeed by means of an is* function, namely isa:

    if isa(f, 'function_handle')
        % f is a handle
    else
        % f is not a handle
    end
    

    edit:
    For completeness, I’d like to point out that using class() works for checking if something is a function handle.
    However, unlike isa, this doesn’t generalize well to other aspects of MATLAB such as object-oriented programming (OOP) that are having an increasing impact on how MATLAB works (e.g. the plot functionality, the control toolbox, the identification toolbox, … are heavily based on OOP).

    For people familiar with OOP: isa also checks the super types (parent types) of the x object for someClass, while strcmp(class(x), 'someClass') obviously only checks for the exact type.

    For people who don’t know OOP: I recommend to use isa(x, 'someClass') instead of strcmp(class(x), 'someClass') as that is the most convenient (and commonly useful) behavior of the two.

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

Sidebar

Related Questions

Why I am getting: Error: One or more models did not validate: test.test: unique_together
Here is my HTML: <script type=text/javascript> $(document).ready(function () { $(#formTest).validate({ rules: { Test: {
I need a function to validate if the content of a variable is a
How do I change validates_numericality_of :test, :greater_than_or_equal_to=>0 into validate form I tried only character
After test driving Google Chrome for 30 minutes or so, I like it, even
How to test input Field Validate a comma exists in a input field ?
I have a group of numeric functions in Clojure that I want to validate
I am trying to compare an encode_base64('test') to the string variable containing the base64
I wanted to validate the below test I wrote to validate the fact that
I am trying to validate year using Regex.test in javascript, but no able to

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.