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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:31:34+00:00 2026-06-09T19:31:34+00:00

I wanted to declare a nonlinear complicated function in Matlab, so I wrote this

  • 0

I wanted to declare a nonlinear complicated function in Matlab, so I wrote this :

>> syms x

>> f=inline((3/2)*(7.02^2))-(2*18*x*((1-(x/18))*(1-(exp(-18/x)))))

but it did not work and it returns this error :

??? Error using ==> inline.inline at 47
Input must be a string.

How can I declare it so that I can use it as a function inside a loop?

I want to find the root of this function numerically, so I first need to declare it, so that I can use it in a loop.

  • 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-09T19:31:35+00:00Added an answer on June 9, 2026 at 7:31 pm

    First, you should learn about operator precedence, so you can avoid many of the confusing brackets you have.

    Second, as most other people have mentioned here, inline is slow and not suited for this purpose. You’re better off using (and leaning how to use properly) anonymous functions, a.k.a. function handles.

    Third, if you want to find the roots of this function, you’d better use an extensively tested Matlab function dedicated to that purpose, rather than design & implement your own version:

    >> f = @(x) 3/2*7.02^2 - 2*18*x.*(1-x/18).*(1-exp(-18./x));    
    >> root1 = fzero(f, 14)
    root1 = 
        1.440303362822718e+01
    
    >> root2 = fzero(f, 2.5)
    root2 = 
         2.365138420421266e+00
    
    >> root3 = fzero(f, 0)    %# (if you're into that kind of perversion)
    root3 = 
        0
    

    I found the initial values by randomly testing values from -100:100 and then unique-ing the outcomes. This is by no means a robust way to find all roots, but I trust you can come up with something better (the problem is fairly straightforward to solve analytically anyway).

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

Sidebar

Related Questions

I wanted to use an ExpandableListView for my Fragment but since it's not native,
We can declare functions inside functions (I wanted a local variable, but it parses
I wanted to use 6 different textures on a cube, one per side, but
How could I call a function from a DLL? I tried to declare a
I just wanted to know what happens behind my program when I declare and
I wanted to throw this out there for some ideas. I'm writing a program
I know how to accomplish my task with .NET, but I wanted to do
I wanted to use the var keyword to declare a field in my class
I wanted to create a function of a certain type. I've found one way
I just wanted to know What are the factors decisive in making a function

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.