Building symbolic expression with vars from vector
Is it possible, to build a symbolic expression with symbolic parameters/variables like in the minimal example below?
syms x y
syms j % index var
m = 10 % max index
p_j = sym(‘p’, [m 2]) % symbolic parameter vector
phi = sym(‘phi’, [m,1]) % symbolic vars
syms J_j(j) % helper expression
J_j(j) = sqrt((x-p_j(j,1))^2+(y-p_j(j,1))^2)*phi(j); % <-fails
J = symsum(J_j(j), j, 1, m) % final expression
The error is probably due to accessing a matrix.
I very much appreciate any response.
Many thanks in advance.Is it possible, to build a symbolic expression with symbolic parameters/variables like in the minimal example below?
syms x y
syms j % index var
m = 10 % max index
p_j = sym(‘p’, [m 2]) % symbolic parameter vector
phi = sym(‘phi’, [m,1]) % symbolic vars
syms J_j(j) % helper expression
J_j(j) = sqrt((x-p_j(j,1))^2+(y-p_j(j,1))^2)*phi(j); % <-fails
J = symsum(J_j(j), j, 1, m) % final expression
The error is probably due to accessing a matrix.
I very much appreciate any response.
Many thanks in advance. Is it possible, to build a symbolic expression with symbolic parameters/variables like in the minimal example below?
syms x y
syms j % index var
m = 10 % max index
p_j = sym(‘p’, [m 2]) % symbolic parameter vector
phi = sym(‘phi’, [m,1]) % symbolic vars
syms J_j(j) % helper expression
J_j(j) = sqrt((x-p_j(j,1))^2+(y-p_j(j,1))^2)*phi(j); % <-fails
J = symsum(J_j(j), j, 1, m) % final expression
The error is probably due to accessing a matrix.
I very much appreciate any response.
Many thanks in advance. symbolic, vector, indexing MATLAB Answers — New Questions