finding the remainder of the division of two symbolic variables
7 次查看(过去 30 天)
显示 更早的评论
I want to get 2*V^2 from the operation below
syms A V
rem(2*V^2+3A,A)
but it seems like rem() function does not work with symbolic variables. Is there a way to achieve this in another way?
5 个评论
Umar
2024-8-3
编辑:Walter Roberson
2024-8-3
Hi @ Elif Cansu Akoguz,
If you manually expand the expression and then extract the coefficients, you can deduce the value of z as A^2 in the rewritten function. Let me illustrate it with example,
syms bL bH A V z t;
f = (A^2*bL^2 + 2*A^2*bL + A^2 + 4*bH^2*bL^2 - 8*bH*bL + 4)/(8*(bH*bL - 1)^2);
% Expand the expression
expanded_f = expand(f);
% Extract the coefficients
coeff_z = coeffs(expanded_f, A^2);
z = coeff_z(1); % Assuming z is the coefficient of A^2
% Verify the result
rewritten_f = z*(1+bL)^2 + t;
This approach will bypass the limitation of the coeffs function with complex arguments. Hope this helps.
回答(1 个)
Aditya
2024-8-1
you can use "quorem" function to get the Quotient and remainder for a particular expression:
here is an example on how to do it:
[q, r] = quorem(expr, A, A);
To read more about this function refer to this link:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!