I want to symbolically define a matrix weighted norm like this:
Obviously I do not want to hard code the dimensions of vector and matrix.
I tried to define a symbolic expression like this:
C_mat_g_term_vec = sym('C_g_T_%d%d', [1, 18]);C_mat_g_term = diag(C_mat_g_term_vec)g_term_vec = sym('g_term_%d%d', [18, 1]);% norm_mat_expr = @(v_in, W_in)((eye(size(v_in, 1), size(v_in,1))*v_in)).'*eye(size(W_in, 1))*W_in*(eye(size(v_in), size(v_in,1))*v_in)
norm_mat_expr = @(v_in, W_in)(v_in).'*W_in*(v_in)norm_mat = sym(norm_mat_expr)norm_mat(g_term_vec, C_mat_g_term)
Giving the error message:
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
R_tilde = builtin('subsref',L_tilde,Idx);
So apparently Matlab Sim-Engine handles symbols as scalars.
Does someone has a practical solution for this? 🙂
The concrete answer is given in the comments below:
C_mat_g_term_vec = sym('C_g_T_%d_%d', [1, 18]);syms C_mat_g_termC_mat_g_term = diag(C_mat_g_term_vec);g_term_vec = sym('g_term_%d_%d', [18, 1]);norm_mat_expr = @(v_in, W_in)(v_in).'*W_in*(v_in)norm_mat_expr(g_term_vec, C_mat_g_term)
Best Answer