Skip to content
Permalink
5079255cc9
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
28 lines (19 sloc) 715 Bytes
%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)');