How do I sum a function in matlab?

5 Ansichten (letzte 30 Tage)
Lid
Lid am 26 Okt. 2016
Kommentiert: wgh Huang am 30 Okt. 2016
Hi,
how do I write a function in matlab, which includes a sum? My goal is to write a function which sums the Lagrange-polynomials..
Can somebody help me?

Antworten (1)

Smith
Smith am 26 Okt. 2016
You can define a function using Anonymous function like this
f1 = @(x) x;
f2 = @(x) x.^2;
to get to sum of f1 and f2, f
f = @(x) f1(x)+f2(x);
and f is equal to x+x^2.
  1 Kommentar
wgh Huang
wgh Huang am 30 Okt. 2016
Cell array will help if there are a lot of functions, which are in a particular pattern.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by