using summation within a function

1 Ansicht (letzte 30 Tage)
Giuseppe Battaglia
Giuseppe Battaglia am 13 Mär. 2016
Kommentiert: Walter Roberson am 11 Jul. 2021
I'm trying to compute something like this:
y=sum(x+n) (or any other f(x))
This only works if n and x have the same dimension as matrix, but what I'm after is to use to derive y =f(x) but so far I had no luck any help is wellcome
  1 Kommentar
Walter Roberson
Walter Roberson am 13 Mär. 2016
In a case like that, what size would you want y to come out as, and what values?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Dave Behera
Dave Behera am 24 Mär. 2016
The x + n part will only work if they are the same dimension. Can you please describe in detail what you are referring to as 'derive y =f(x)'?
  2 Kommentare
Sa'adatu Abubakar
Sa'adatu Abubakar am 10 Jul. 2021
I want to use the summation function inside the newtonRaphson algorithm, how can I express it I used symsum(f,k,a,b) but it dosnt work. Do I need to use for loop?
Walter Roberson
Walter Roberson am 11 Jul. 2021
sum(arrayfun(@f, a:b))
If f returns a non-scalar value then you might need
temp = arrayfun(@f, a:b, 'uniform', 0);
nd = ndims(temp{1});
y = sum(cat(nd+1, temp{:}),nd+1);

Melden Sie sich an, um zu kommentieren.


Mehr zu Mathematics 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