Create a function of n variables
Mostra commenti meno recenti
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:
- Is there a way to create this function without specifying n? That is (without the powers to simplify the question):

- 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
Più risposte (0)
Categorie
Scopri di più su Assumptions in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!