Explorar o código

Problems 2? and 3 done, still have to finish 1

Pjotir hai 4 semanas
pai
achega
7b77591162

+ 9 - 0
Homework3/problem1_potentialwell.m

@@ -0,0 +1,9 @@
+clear all; clc; close all;
+
+% Janky constants
+hbar = 1;
+m = 1;
+v1 = 30;
+v2 = 40;
+L = 1;
+N = 1000;

+ 12 - 0
Homework3/problem2_markovchain.m

@@ -0,0 +1,12 @@
+clear all; close all; clc;
+
+transition = [0.5 .25 .25;
+              0.25 0.5 0.25;
+              0.4 0.4 0.2]
+
+transition_transposed = transition';
+[V, D] = eig(transition_transposed)
+eigen_values = diag(D)
+[val, one_index] = min(abs(eigen_values-1))
+eigen_vector = V(:, one_index)
+eigen_vector = eigen_vector/sum(eigen_vector)

+ 19 - 0
Homework3/problem3_2ndorderODE.m

@@ -0,0 +1,19 @@
+clear all; close all; clc;
+
+ode_system = @(t, Y) [
+    Y(2);
+    -3 - (t^2 + Y(1))*Y(1) - (3*t+2*Y(1))*Y(2)
+];
+
+t_span = [0, 10];
+initial_conditions = [1; 0];
+
+[t, Y] = ode45(ode_system, t_span, initial_conditions);
+figure;
+hold on;
+grid on;
+plot(t, Y(:, 1));
+plot(t, Y(:, 2));
+legend("y(t)", "y'(t)");
+xlabel("t");
+ylabel("y(t) & y'(t)");