Solve with several vectors
Show older comments
Hi, I have these vectors:
int_v_d
int_i_d
i_d
int_omega_i_q
int_v_q
int_i_q
i_q
int_omega_i_d
theta
All of them have the same size and each of them is a column vector.
Now, I have a set of two equations like this one:
eq_1 = int_v_d == -R_AFPM * int_i_d - (i_d - i_d(1)) .* L_d + L_q .* int_omega_i_q;
eq_2 = int_v_q == -R_AFPM * int_i_q - (i_q - i_q(1)) .* L_q - L_d .* int_omega_i_d + ...
psi_f * theta;
The variables that are not vectors, and that I didn't mention before, are constants. I want to calculate the values L_d and L_q for each row.
I am using solve and subs functions for this, but I get this error:
Error using symengine
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function
first to substitute values for variables.
Error in sym/double (line 709)
Xstr = mupadmex('symobj::double', S.s, 0);
Here is my complete code:
syms int_v_d int_i_d i_d int_omega_i_q int_v_q int_i_q i_q int_omega_i_d theta L_d L_q
eq_1 = int_v_d == -R_AFPM * int_i_d - (i_d - i_d(1)) .* L_d + L_q .* int_omega_i_q;
eq_2 = int_v_q == -R_AFPM * int_i_q - (i_q - i_q(1)) .* L_q - L_d .* int_omega_i_d + ...
psi_f * theta;
sol = solve([eq_1;eq_2],[L_d;L_q]);
vec_L_d = double(subs(sol.L_d,{int_v_d;int_i_d;i_d;int_omega_i_q; ...
int_v_q;int_i_q;i_q;int_omega_i_d;theta},{int_v_d;int_i_d;i_d;int_omega_i_q; ...
int_v_q;int_i_q;i_q;int_omega_i_d;theta}));
vec_L_q = double(subs(sol.L_q,{int_v_d;int_i_d;i_d;int_omega_i_q; ...
int_v_q;int_i_q;i_q;int_omega_i_d;theta},{int_v_d;int_i_d;i_d;int_omega_i_q; ...
int_v_q;int_i_q;i_q;int_omega_i_d;theta}));
The result for L_d and L_q should be for each one a vector of the same size as the other vectors.
Thank you in advance.
2 Comments
Walter Roberson
on 19 Aug 2022
syms int_i_d
does not declare a vector. You need a size after it
eq_1 = int_v_d == -R_AFPM * int_i_d - (i_d - i_d(1)) .* L_d + L_q .* int_omega_i_q;
eq_2 = int_v_q == -R_AFPM * int_i_q - (i_q - i_q(1)) .* L_q - L_d .* int_omega_i_d + ...
psi_f * theta;
"The variables that are not vectors, and that I didn't mention before, are constants."
So L_q and L_d are constants, since you did not mention them before? Scalar constants?
"The result for L_d and L_q should be for each one a vector of the same size as the other vectors."
That would require that they are symbolic vectors since you are solving for them.
Luciano Montanelli
on 19 Aug 2022
Edited: Luciano Montanelli
on 19 Aug 2022
Accepted Answer
More Answers (0)
Categories
Find more on Symbolic Variables, Expressions, Functions, and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!