Borrar filtros
Borrar filtros

Error in matlab?

2 visualizaciones (últimos 30 días)
Eugene
Eugene el 13 de Sept. de 2018
Comentada: Denis Perotto el 15 de Sept. de 2018
[A,B,t,r]=solve('e^(-i*k*a)+r^(i*k*a)=A*e^(-i*q*a)+B*e^(i*q*a)', ...
'A*e^(i*q*a)+B*e^(-i*q*a)=t*e^(-i*k*a)', ...
'i*k*(e^(-i*k*a)-r*e^(i*k*a))=i*q*(A*e^(-i*q*a)-B*e^(i*q*a))', ...
'i*q*(A*e^(-i*q*a)-B*e^(-i*q*a))=i*k*t*e^(i*k*a)')
end
Error:Expression or statement is incorrect--possibly unbalanced (,{,or[.
Image of code
  7 comentarios
Eugene
Eugene el 14 de Sept. de 2018
i need function like simplify in maple
Walter Roberson
Walter Roberson el 14 de Sept. de 2018
simplify() exists in MATLAB, but maple simplify is mostly more powerful. maple simplify is not enough to solve this problem.
Please verify whether q = sqrt(k^2+2*m*mu_0/A^2)

Iniciar sesión para comentar.

Respuestas (1)

Denis Perotto
Denis Perotto el 14 de Sept. de 2018
Are you sure, that these equations aren't wrong? For example, you can divide 3rd equation by i. The system is nonlinear and MATLAB cannot solve it symbolically:
Ты уверен, что у тебя правильно записана система уравнений? В 3-м уравнении, как минимум, можно сократить на i. Система нелинейная и в символьном виде MATLAB ее не решает:
syms r A B t k a q;
equations = [exp(-1i * k * a) + r ^ (1i * k * a) == A * exp(-1i * q * a) + B * exp(1i * q * a), ...
A * exp(1i * q * a) + B * exp(-1i * q * a) == t * exp(-1i * k * a), ...
1i * k * (exp(-1i * k * a) - r * exp(1i * k * a)) == 1i * q * (A * exp(-1i * q * a) - B * exp(1i * q * a)), ...
1i * q * (A * exp(-1i * q * a) - B * exp(-1i * q * a)) == 1i * k * t * exp(1i * k * a)];
vars = [r A B t];
S = solve(equations, vars);
As a result, struct S has null fields and we get a warning:
В результате S имеет нулевые поля и вылезает предупреждение:
Warning: Cannot find explicit solution
Please, check your equations or solve them numerically.
Либо ищи ошибку в записи уравнений/упрощай их и пытайся решить. Либо не мучайся и решай численно.
  3 comentarios
Walter Roberson
Walter Roberson el 14 de Sept. de 2018
Nonlinear equations often do not have closed form solutions.
Denis Perotto
Denis Perotto el 15 de Sept. de 2018
Не решает, потому что система нелинейная; большинство нелинейных систем в символьном виде не решаются, поэтому я и посоветовал решать численно. Если численно ну совсем никак, попробуй упростить выражения, поделив на i 3 и 4 уравнения, как минимум. Может, можно экспоненты в sin и cos преобразовать по формуле Эйлера, поиграйся, авось MATLAB и решит. За основу можешь взять мой код, он рабочий. Только уравнения новые впиши.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by