Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

passed to equation that has variable of symbolic

1 visualización (últimos 30 días)
je heo
je heo el 3 de Ag. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I want to get solution of literaion this code by passing equation that has variable of symbolic
syms Z1 Z2 Z3 Za Zc C L
k=10;
for i = 1:k
Z11 = 2*Z1 +Z3 == (Za + Zc)^2/(2*(Za+Zc))
Z21 = Z3 == (Za^2-Zc^2)/(2*(Za+Zc))
eqn1 = [Z11,Z21];
[Za, Zc] = solve(eqn1,[Za,Zc])
%[Za, Zc] = update_var(Za,Zc)
[Za] = simplify(parallel(Za,C))
Z11 = 2*Z1 +Z3 == (Za + Zc)^2/(2*(Za+Zc))
Z21 = Z3 == (Za^2-Zc^2)/(2*(Za+Zc))
eqn2 = [Z11,Z21]
[Z1, Z3] = solve(eqn2,[Z1,Z3])
[Z1] = simplify(serial1(Z1,L))
% after solve equation, Z1,Za is overwritten with a expression, sol of equation?
end

Respuestas (1)

Walter Roberson
Walter Roberson el 4 de Ag. de 2020
Editada: Walter Roberson el 4 de Ag. de 2020
as discussed in https://www.mathworks.com/matlabcentral/answers/570979-second-argument-must-be-a-vector-of-symbolic-variables#answer_471310 your equations as stated cannot be solved. After the first iteration, Z1 is no longer a symbolic variable (it is a symbolic expression instead) and so you cannot solve for it.
  2 comentarios
je heo
je heo el 4 de Ag. de 2020
Thank you for your answer. then, Is there any way to solve the equation using syms variable??
Walter Roberson
Walter Roberson el 4 de Ag. de 2020
I do not know. Maybe you could get something useful with the below. It treats each iteration as having a Z1 and Z3 to be added to the previous Z1 Z3 values.
syms Z2 Za Zc C L
k=10;
Z1 = syms(Z1, [1 k+1]);
Z3 = syms(Z1, [1, k+1]);
Z1(1) = 0;
Z3(1) = 0;
for i = 1:k
Z11 = 2*sum(Z1(1:k+1)) + sum(Z3(1:k+1)) == (Za + Zc)^2/(2*(Za+Zc));
Z21 = sum(Z3(1:k+1)) == (Za^2-Zc^2)/(2*(Za+Zc));
eqn1 = [Z11,Z21];
[Za, Zc] = solve(eqn1,[Za,Zc]);
%[Za, Zc] = update_var(Za,Zc)
[Za] = simplify(parallel(Za,C));
Z11 = 2*sum(Z1(1:k+1)) + sum(Z3(1:k+1)) == (Za + Zc)^2/(2*(Za+Zc));
Z21 = sum(Z3(1:k+1)) == (Za^2-Zc^2)/(2*(Za+Zc));
eqn2 = [Z11,Z21];
[Z1(k+1), Z3(k+1)] = solve(eqn2,[Z1(k+1),Z3(k+1)]);
[Z1(k+1)] = simplify(serial1(Z1(K+1),L));
end
cumsum(Z1)
cumsum(Z3)
We do not have parallel() or serial1() to test this out with... and we probably would not know if the answer was reasonable or not.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by