Hello,
I have a few questions concerning the same function. I am trying to recreate the following function:
For a specific n and a=1, I have the following code:
n = 5 ;
syms b ;
x = sym('x', [1 n]) ;
f = sum(x)^(1/b)
I was wondering:
  1. Is there a way to create this function without specifying n? That is (without the powers to simplify the question):
  2. In my above code, I assumed a=1. If I try to include any power to x, I get an error.
So far I tried:
n = 5 ;
syms b ;
syms a ;
x = sym('x', [1 n]) ;
f=sum(x^a)^(1/b)
& (using a = 2 as a test)
n = 5 ;
syms b ;
x = sym('x', [1 n]) ;
f=sum(x^2)^(1/b)
Both resulted in the following error:
Error using symengine
Not a square matrix.
Error in sym/privBinaryOp (line 1002)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in ^ (line 325)
B = privBinaryOp(A, p, 'symobj::mpower');
It's worth mentioning I'm entirely new to Matlab, so I'm still trying to make sense of everything.
Thanks in advance,

 채택된 답변

madhan ravi
madhan ravi 2019년 1월 11일

1 개 추천

.^ instead of ^ % lookup element wise operation

댓글 수: 3

Michaël de Clercq
Michaël de Clercq 2019년 1월 11일
Thank you! I saw .* for multiplication but since I didn't look into it yet, I suppose my brain didn't think about trying .^. Would you happen to know the answer to my first question as well? I'm interested in the general behaviour of the function. For example a=b < 1 results in concavity. Although n would be irrelevant for this, I'd like to be able to prove this in Matlab without having to specify n.
madhan ravi
madhan ravi 2019년 1월 11일
perhaps you want to use symsum()
Michaël de Clercq
Michaël de Clercq 2019년 1월 11일
편집: Michaël de Clercq 2019년 1월 11일
I looked into it using symsum() first, but that way I couldn't even recreate the function for a specified n, let alone use it to evaluate for an unspecified n. Looking into it again atm.

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

추가 답변 (0개)

카테고리

Community Treasure Hunt

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

Start Hunting!

Translated by