Al momento, stai seguendo questa domanda
- Vedrai gli aggiornamenti nel tuofeed del contenuto seguito.
- Potresti ricevere delle e-mail a seconda delle tuepreferenze per le comunicazioni.
Mismatched Stability check.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1710301/image.png)
21 Commenti
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1710351/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1710356/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1710601/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1710606/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1710371/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1710376/image.png)
Here's the code checking the eigenvalues. As I could see, eigenvalues for t are near zero but eigenvalues for k are quite large.
Should I take different perturbation for k and t?
% Define the equations as anonymous functions eq1 = @(vars, m) (sqrt(vars(1))/sqrt(1-vars(1))) + ((vars(2)*(2*(m^3) + vars(2)^3 - 3*vars(2)*((m+1)^2))^2)/(6*vars(2) - 3*((m-vars(2))^2)) + ((m-vars(2))^2)*(m+2*vars(2))*(m/(3*vars(2)) + 2/3)) / ((m^3 - (vars(2)^2)*(3*m+3) + 2*(vars(2)^3))*(m/(3*vars(2)) - (2*m+vars(2))/(3*(2*vars(2)-((m-vars(2))^2))) + 2/3) - vars(2)*((m-vars(2))^2)*(2*m+vars(2))*((2*m/3) + vars(2)/3)); eq2 = @(vars, m) vars(2) - ((sqrt(vars(1))/sqrt(1-vars(1)))*(((m/vars(2))+2)/3) - (1/3)*(2 + (m/vars(2)) + ((2*m+vars(2))/(((m-vars(2))^2)-2*vars(2))))) / ((sqrt(vars(1))/sqrt(1-vars(1)))*(2*(m^3) - 3*((1+m)^2)*vars(2) + vars(2)^3)/(3*(((m-vars(2))^2)-2*vars(2))) - ((2*m+vars(2))/3));
% Define the range of m values m_values = linspace(0, 1, 100); % 100 values of m between 0 and 1
% Preallocate arrays to store solutions k_solutions = zeros(size(m_values)); t_solutions = zeros(size(m_values)); stabilities = cell(size(m_values));
% Loop over m values and solve the system of equations for each m for i = 1:length(m_values) m = m_values(i);
% System of equations for current m system_of_equations = @(vars) [eq1(vars, m); eq2(vars, m)];
% Initial guess for [k, t] initial_guess = [0.75, 1.5];
% Solve the system of equations using fsolve options = optimoptions('fsolve', 'Display', 'off'); [solution, ~, exitflag] = fsolve(system_of_equations, initial_guess, options);
% Check if fsolve converged if exitflag > 0 % Store solutions if they meet the criteria k_solution = solution(1); t_solution = solution(2);
if k_solution > 0.5 && k_solution < 1 && t_solution > 0 k_solutions(i) = k_solution; t_solutions(i) = t_solution;
% Compute the Jacobian matrix using finite differences delta = 1e-6; J = zeros(2); % Initialize Jacobian matrix
% Compute f_original once outside the loop f_original = system_of_equations(solution);
% Calculate the partial derivatives for the Jacobian matrix for j = 1:2 perturbed_solution = solution; perturbed_solution(j) = perturbed_solution(j) + delta; f_perturbed = system_of_equations(perturbed_solution); J(:, j) = (f_perturbed - f_original) / delta; end
% Calculate eigenvalues of the Jacobian matrix eigenvalues = eig(J);
% Debug: print eigenvalues for inspection fprintf('m = %.2f, k = %.4f, t = %.4f, Eigenvalues: %.6f, %.6f\n', m, k_solution, t_solution, eigenvalues(1), eigenvalues(2));
% Analyze stability if all(real(eigenvalues) < 0) stabilities{i} = 'Stable'; elseif all(real(eigenvalues) == 0) % Use center manifold method for stability analysis % Modify this part with your center manifold method implementation stabilities{i} = 'Center manifold method'; elseif any(real(eigenvalues) > 0) stabilities{i} = 'Unstable'; end else k_solutions(i) = NaN; t_solutions(i) = NaN; stabilities{i} = 'NaN'; end else k_solutions(i) = NaN; t_solutions(i) = NaN; stabilities{i} = 'NaN'; end end
% Display solutions and stabilities disp('Solutions for each m:'); for i = 1:length(m_values) fprintf('m = %.2f, k = %.4f, t = %.4f, Stability = %s\n', m_values(i), k_solutions(i), t_solutions(i), stabilities{i}); end
% Plot solutions figure; plot(m_values, k_solutions, '-o', 'DisplayName', 'k'); hold on; plot(m_values, t_solutions, '-o', 'DisplayName', 't'); xlabel('m'); ylabel('Values'); title('Solutions as a Function of m'); legend('k', 't'); hold off;
% Plot stability figure; plot(m_values, strcmp(stabilities, 'Stable'), '-o', 'DisplayName', 'Stable'); hold on; plot(m_values, strcmp(stabilities, 'Unstable'), '-o', 'DisplayName', 'Unstable'); xlabel('m'); ylabel('Stability'); title('Stability as a Function of m'); legend('Stable', 'Unstable'); hold off;
Risposte (0)
Vedere anche
Categorie
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia-Pacifico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)