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,

 Risposta accettata

.^ instead of ^ % lookup element wise operation

3 Commenti

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.
perhaps you want to use symsum()
Michaël de Clercq
Michaël de Clercq il 11 Gen 2019
Modificato: Michaël de Clercq il 11 Gen 2019
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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by