using summation within a function

조회 수: 1 (최근 30일)
Giuseppe Battaglia
Giuseppe Battaglia 2016년 3월 13일
댓글: Walter Roberson 2021년 7월 11일
I'm trying to compute something like this:
x=1:100
n=1:10
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
thanks
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 3월 13일
In a case like that, what size would you want y to come out as, and what values?

댓글을 달려면 로그인하십시오.

답변 (1개)

Dave Behera
Dave Behera 2016년 3월 24일
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
Sa'adatu Abubakar
Sa'adatu Abubakar 2021년 7월 10일
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 2021년 7월 11일
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);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by