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/ME3255_HW4_mininumPE.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (23 sloc)
692 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
%ME3255 | |
%Homework 4 | |
%Find minimum stuff | |
theta = 0; | |
x_l = 0; | |
x_u = 10; | |
%b) test collar_potential_energy | |
U_min = goldmin(@(x) collar_potential_energy(x, theta), x_l, x_u); | |
%c) find x_min for theta = 0 to 90 | |
theta_u = degtorad(90); %upper limit of theta | |
theta = linspace(0, theta_u); %values of theta in radians; | |
%loop through values | |
for i = 1:length(theta) | |
[x_min(i), U_min(i)] = goldmin(@(x) collar_potential_energy(x, theta(i)), x_l, x_u); | |
end | |
plot(U_min, theta); | |
%formatting chart | |
title('Minimum PE vs. theta'); | |
ylabel('Total U (J)'); | |
xlabel('theta (rad)'); | |
xticks([0, pi/16, pi/8, 3*pi/16]) | |
xticklabels({'0','\pi/16', '\pi/8', '\pi/16'}) %yay Tex! | |
print('minPEplot.png', '-dpng'); |