Solving a symbolic equation in one or more variables
Afficher commentaires plus anciens
When the following code is executed, the output is
ans =
Empty sym: 0-by-1
although b = i = yp = [1 90]
I get the same result when I let b = [1 90] or yp instead of r2p(i), although [1 90] = 1 ∠90 degrees = i. Does anyone have suggestions regarding how I should modify the code so that r2p(i) is understood to mean [1 90] (1 ∠90 degrees)? When r2p(i) is typed in the command window, the output is correct.
f = @(x,y) 2*x*y;
x = f(30,3)*2;
r2p = @(x) [abs(x) rad2deg(angle(x))]; % Rectangular -> Phasor
p2r = @(x) x(1)*exp(1i*deg2rad(x(2))); % Phasor -> Rectangular
pm = @(x,y) [x(1)*y(1) x(2)+y(2)]; % Phasor Multiply
pd = @(x,y) [x(1)/y(1) x(2)-y(2)]; % Phasor Divide
x = 3+4i;
xp = r2p(x);
yp = [1 90];
xptimesyp = pm(xp,yp);
xrtimesyr = p2r(xptimesyp);
Check = x * p2r(yp);
syms a b c
eqn = b==r2p(i);
solve(eqn,b)
Réponse acceptée
Plus de réponses (1)
Tommy
le 20 Avr 2020
Your equation is
>> eqn
eqn =
[ b == 1, b == 90]
which has no solution.
You could specify that b should be a 1x2 vector:
r2p = @(x) [abs(x) rad2deg(angle(x))]; % Rectangular -> Phasor
syms b [1 2]
eqn = b==r2p(1i);
>> eqn
eqn =
[ b1 == 1, b2 == 90]
which gives
S = solve(eqn,b);
>> disp([S.b1 S.b2])
[ 1, 90]
1 commentaire
Aleem Andrew
le 20 Avr 2020
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!