Create a function of n variables
이전 댓글 표시
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,
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!