Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
roots_and_optimization/HW4_Script.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
28 lines (19 sloc)
715 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%HW_4 Script | |
setdefaults; | |
%Part B: using the goldmin function | |
theta = 0; | |
[x1,fx1,ea1,iter1] = goldmin(@(x) collar_potential_energy(x,theta),-10,10,0.0001); | |
%Part C: Creating For-loop solving for potential energy | |
theta = .9*pi/180; | |
thetaVector = linspace(0,pi, 400); | |
fx2 = 0; | |
[x3,fx3,ea3,iter3] = goldmin(@(x) collar_potential_energy(x,theta),-10,10,0.0001); | |
for n = 1:length(thetaVector) | |
theta = thetaVector(n); | |
[x2,fx2(n),ea2,iter2] = goldmin(@(x) collar_potential_energy(x,theta),-10,10,0.0001); | |
end | |
%Part D: Plotting the Data | |
plot(thetaVector, fx2); | |
title('Plot of Minimum PE for x_C with given Angle'); | |
xlabel('Theta (radians)'); | |
ylabel('x_C (meters)'); | |