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