I was trying to create a array of symfun
, so that I may later access those functions and perform the diff
operation w.r.t to the specific variables, I have searched and found the code as:
syms x
f = symfun([x1^2+x2-x3; x2+x3^2; x1*x2], x);
But is not the thing that I am looking for, this snippet is creating a symfun
out of an array, but I need to create an array of symfun
. So that if I have n
symfun
stored in an array and also have n
variables stored in an array then want to create a matrix with the following rule:
[[diff(func_1, x1) diff(func_1, x2) ...... diff(func_1, xn)]
[diff(func_2, x1) diff(func_2, x2) ...... diff(func_2, xn)]
.
.
.
.
[diff(func_n, x1) .......................... diff(func_n, xn)]]
And here is my code:
function[K] = bigPopaPump()
x1 = sym('x1')
x2 = sym('x2')
f1 = symfun(3*x1+2, x1)
f2 = symfun(8*x2+5, x2)
funcs = [f1, f2]
xess = [x1, x2]
dummy_array = zeros(2, 2)
for i = 1:size(funcs)
for j = 1:size(funcs)
dummy_array(i, j) = diff(funcs(i), xess(j));
end
end
display dummy_array
end