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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:49:02+00:00 2026-05-19T04:49:02+00:00

Hi I am trying to sum two function handles, but it doesn’t work. for

  • 0

Hi
I am trying to sum two function handles, but it doesn’t work.
for example:

y1=@(x)(x*x);
y2=@(x)(x*x+3*x);
y3=y1+y2

The error I receive is “??? Undefined function or method ‘plus’ for input arguments of type ‘function_handle’.”

This is just a small example, in reality I actually need to iteratively sum about 500 functions that are dependent on each other.

EDIT
The solution by Clement J. indeed works but I couldn’t manage to generalize this into a loop and ran into a problem. I have the function s=@(x,y,z)((1-exp(-x*y)-z)*exp(-x*y)); And I have a vector v that contains 536 data points and another vector w that also contains 536 data points. My goal is to sum up s(v(i),y,w(i)) for i=1…536 Thus getting one function in the variable y which is the sum of 536 functions. The syntax I tried in order to do this is:

sum=@(y)(s(v(1),y,z2(1))); 
for i=2:536 
  sum=@(y)(sum+s(v(i),y,z2(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-19T04:49:03+00:00Added an answer on May 19, 2026 at 4:49 am

    The solution proposed by Fyodor Soikin works.

    >> y3=@(x)(y1(x) + y2(x))
    y3 =
    @(x) (y1 (x) + y2 (x))
    

    If you want to do it on multiple functions you can use intermediate variables :

    >> f1 = y1;
    >> f2 = y2;
    >> y3=@(x)(f1(x) + f2(x))
    

    EDIT after the comment:
    I’m not sure to understand the problem. Can you define your vectors v and w like that outside the function :

    v = [5 4]; % your 536 data
    w = [4 5];
    y = 8;
    s=@(y)((1-exp(-v*y)-w).*exp(-v*y))
    s_sum = sum(s(y))
    

    Note the dot in the multiplication to do it element-wise.

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

Sidebar

Related Questions

I've got two tables. I'm trying to calculating the SUM quantity of tbl1 tbl1.xid
as the title states, I am trying to add two floats using javascript/jquery, and
I am trying to produce some example graphics using ggplot2, and one of the
Hi I am trying to take two arrays and turn them into one 2
I am trying to take a two-dimensional array and run it through a series
While trying to extract data from a view by joining it with two other
I'm trying to figure out the overall ratio for users. There is basically two
I have created this little program to calculate pi using probability and ratios. In
I have the following LINQ conditional where clause query that produces a result of
So the other day, I asked this question about how to combine three complex

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.