Question
Write a function file U.m that returns the potential energy, U. Find the minimal energy for n = 3 using fminsearch in MATLAB. Try several
Write a function file U.m that returns the potential energy, U. Find the minimal energy for n = 3 using fminsearch in MATLAB. Try several initial guesses until you are convinced you have the absolute minimum.
Then use the Matlab command plot3 to plot the three atoms in the minimum energy configuration as circles, and connect all circles with line segments to view the conformed molecule.
It's given how the U.m could look like:
function out = U ( p_in )
% p_in is for the unknown values
% For N = 3, the unknown values are z_2, x_3, y_3,z_3 and for N=4, the unknown values are z_2 , x_3 , y_3 , z_3 , x_4 , y_4, z_4 etc
% p_fix are for the values that has fixed values
% Atom 1 is
p_fix (1) = 0.0; % x_1
p_fix (2) = 0.0; % y_1
p_fix (3) = 0.0; % z_1
% Atom 2 isbound to the z-axis
p_fix (4) = 0.0; % x_2
p_fix (5) = 0.0; % y_2
p = [ p_fix , p_inn ]; % All values in one vector
% now the x_1 = p(1) , y_1 = p (2) , z_1 = p (3) , x_2 = p (4) etc .
% One slice of the values of p is
p_x = p ([1:3: end ]) % This vector only oincludes the x-values
np = length ( p ) ; if ( mod ( np , 3) ~= 0)
error ('The length must be multible by 3')
end
%THE CODE TO FIND U (THE POTENTIAL ENERGY)
end
And it's given that the minimal energy can be found using the code
[p_out, f_min]=fminsearch(@U, p0)
(The lowest for N=3 is U=-3)
- ( - ) , ij = : - #j)? + : - 9) + - j2 . () - - ( - ) , ij = : - #j)? + : - 9) + - j2 . ()Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started