Skip to content
Permalink
39c43a545a
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
31 lines (23 sloc) 692 Bytes
%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');