% Least squares fit programme for uni-directional CFRP % the programme will find the estimated elastic constants to produce a % curve which is as close as can be to the recorded curve. % This programme does all elastic constants at once. % The programme may be run for the individual samples or the average of the % samples. % Copyright David Paterson, University of Strathclyde, Glasgow, UK. % Reuse or reuse with editing is permitted but must cite the author of this work. % David A.P. Paterson, "Life Cycle and Ultrasonic Based Non-Destructive Analysis of Recycled and Remanufactured Carbon Fibre Reinforced Plastic Composite", % Doctoral Thesis, Univeristy of Strathclyde, Glasgow, 2018 % Equations for transverse isotropic calculated constants may be found from % Castellano, A., Foti, P., Fraddosio, A., Marzano, S., Piccioni, M.D., 2014. % Mechanical characterization of CFRP composites by ultrasonic immersion tests: Experimental and numerical approaches. % Composites Part B Engineering. 66, 299–310. doi:10.1016/j.compositesb.2014.04.024 %======================== Counters ================================================================================ counter = 1; % sets up a counter variable for later on in the programme counter2 = 1; % sets up counter variable for creating velocities array_counter1 = 1; % sets up counter variable for storing the minimum elastic constant values Minimizeloop = 0; % sets up counter variable for while loop %======================== Counters =============================================================================== %======================== Arrays ================================================================================= sindrefract = zeros(1,A); %sets up an array of sin(refraction angles) required to allow refraction angle to be created Refract = zeros(1,A); %sets up an array of refraction angles needed later on for minimizing sum sindrefractL = zeros(1,A);%sets up an array of sinde of refraction angles needed later on for minimization sum RefractL = zeros(1,A); %sets up an array of refraction angles needed later on for minimizing sum c_min_array = zeros(50,12);%sets up an array which can store the c_min values %======================== Arrays ================================================================================== %======================== Inital elastic constants guess ============================================================================== % choice is at the end of programme on line 284 and 288 %======================== Inital elastic constants guess ============================================================================== %======================== Velocities ====================================================================================================== %This part of the programme will allow the user to select which sample velocities to use or even the average of all samples %======================== Velocities ====================================================================================================== %This part of the programme will allow the user to select which sample velocities to use or even the average of all samples %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 1 %%%%%%%%%%%%%%% Sample1_1_2_VL = [A B C D E F G H etc]; % 1-2 plane for sample 1 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample1_1_2_VT = [I J K L M N O P etc]; % 1-2 plane for sample 1 and transverse velocities from experiment %Incident Angle = [9,10,11,12,13,14,15,16 etc...] Sample1_1_3_VL = [A B C D E F G H etc]; % 1-3 plane for sample 3 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample1_1_3_VT = [I J K L M N O P etc]; % 1-3 plane for sample 3 and and transverse velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 1 %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 2 %%%%%%%%%%%%%%% Sample2_1_2_VL = [A B C D E F G H etc]; % 1-2 plane for sample 1 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample2_1_2_VT = [I J K L M N O P etc]; % 1-2 plane for sample 1 and transverse velocities from experiment %Incident Angle = [9,10,11,12,13,14,15,16 etc...] Sample2_1_3_VL = [A B C D E F G H etc]; % 1-3 plane for sample 3 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample2_1_3_VT = [I J K L M N O P etc]; % 1-3 plane for sample 3 and and transverse velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 2 %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 3 %%%%%%%%%%%%%%% Sample3_1_2_VL = [A B C D E F G H etc]; % 1-2 plane for sample 1 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample3_1_2_VT = [I J K L M N O P etc]; % 1-2 plane for sample 1 and transverse velocities from experiment %Incident Angle = [9,10,11,12,13,14,15,16 etc...] Sample3_1_3_VL = [A B C D E F G H etc]; % 1-3 plane for sample 3 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample3_1_3_VT = [I J K L M N O P etc]; % 1-3 plane for sample 3 and and transverse velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 3 %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 4 %%%%%%%%%%%%%%% Sample4_1_2_VL = [A B C D E F G H etc]; % 1-2 plane for sample 1 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample4_1_2_VT = [I J K L M N O P etc]; % 1-2 plane for sample 1 and transverse velocities from experiment %Incident Angle = [9,10,11,12,13,14,15,16 etc...] Sample4_1_3_VL = [A B C D E F G H etc]; % 1-3 plane for sample 3 and longitudinal velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] Sample4_1_3_VT = [I J K L M N O P etc]; % 1-3 plane for sample 3 and and transverse velocities from experiment %Incident Angle = [0,1,2,3,4,5,6,7,8 etc...] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sample 4 %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Average velocities %%%%%%%%%%%% Exp_1_2_VL = ((Sample1_1_2_VL + Sample2_1_2_VL + Sample3_1_2_VL + Sample4_1_2_VL)/4); %Average velocites from all sample measurements Exp_1_2_VT = ((Sample1_1_2_VT + Sample2_1_2_VT + Sample3_1_2_VT + Sample4_1_2_VT)/4); %Average velocites from all sample measurements Exp_1_3_VL = ((Sample1_1_3_VL + Sample2_1_3_VL + Sample3_1_3_VL + Sample4_1_3_VL)/4); %Average velocites from all sample measurements Exp_1_3_VT = ((Sample1_1_3_VT + Sample2_1_3_VT + Sample3_1_3_VT + Sample4_1_3_VT)/4); %Average velocites from all sample measurements %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Average velocities %%%%%%%%%%%% %======================== Material Density and reference velocity ============================================================================================ P = ((A/((B))*1000)+(A/((B))*1000)+(A/((B))*1000)+(A/((B))*1000))/4; % density equations (Mass/Volume)) for each samples then divide by total number of samples SampleV_in_water = (A+B+C+D)/4; %======================== Material Density and reference velocity============================================================================================ %%%%%%%%%%%%%%%% Single velocities (comment out average velocites and select the sample of choice %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Exp_1_2_VL = Sample1_1_2_VL; % Exp_1_2_VT = Sample1_1_2_VT; % Exp_1_3_VL = Sample1_1_3_VL; % Exp_1_3_VT = Sample1_1_3_VT; % P = (A/((B))*1000); % SampleV_in_water = (C); % Exp_1_2_VL = Sample2_1_2_VL; % Exp_1_2_VT = Sample2_1_2_VT; % Exp_1_3_VL = Sample2_1_3_VL; % Exp_1_3_VT = Sample2_1_3_VT; % P = (A/((B)))*1000; % SampleV_in_water = (C); % Exp_1_2_VL = Sample3_1_2_VL; % Exp_1_2_VT = Sample3_1_2_VT; % Exp_1_3_VL = Sample3_1_3_VL; % Exp_1_3_VT = Sample3_1_3_VT; % P = (A/((B)))*1000; % SampleV_in_water = (C); % Exp_1_2_VL = Sample4_1_2_VL; % Exp_1_2_VT = Sample4_1_2_VT; % Exp_1_3_VL = Sample4_1_3_VL; % Exp_1_3_VT = Sample4_1_3_VT; % P = (A/((B)))*1000; % SampleV_in_water = (C); %%%%%%%%%%%%%%%% Single velocities (comment out average velocites and select the sample of choice %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %=================================== Refraction angles transverse =========================================================================== while counter == 1 Incident = [A B C D E F G H I J K etc]; % sets up the Incident angles sindrefract(counter2) = ((sind(Incident(counter2)))*Exp_VT_1_3(counter2))/(SampleV_in_water); % calculates the sinde of refraction angle Refract(counter2) = asind(sindrefract(counter2)); % calcualtes the refraction anlge (this is the anlge the way travels through sample in) counter2 = counter2+1; % increases counter2 variable to allow for moves to create new refraction angle. if counter2 == A % (limited here by number of incident angles) counter = 0; % sets the while loop counter value and exists while loop else counter = 1; % sets the while loop counter value end % end of if else statement end % end of while loop %=================================== Refraction angles transverse =========================================================================== %%==================================== Refraction angles longitudinal ====================================================================== counter = 1; % resets the counter counter2 = 1; % resets the counter while counter == 1 IncidentL = [A B C D E F G H I J K etc]; % sets up the Incident angles sindrefractL(counter2) = ((sind(IncidentL(counter2)))*Exp_VL_1_3(counter2))/(SampleV_in_water); % calculates the sinde of refraction angle RefractL(counter2) = asind(sindrefractL(counter2)); % calcualtes the refraction anlge (this is the anlge the way travels through sample in) counter2 = counter2+1; % increases counter2 variable to allow for moves to create new refraction angle. if counter2 == 6 %(limited here by number of incident angles) counter = 0; % sets the while loop counter value and exists while loop else counter = 1; % sets the while loop counter value end % end of if else statement end % end of while loop % ==================================== Refraction angles longitudinal ====================================================================== counter = 1; % resets the variable to allow it to be used later on counter2 = 1; % resets the variable to allow it to be used later on %============================================================================================================================================== % LEAST SQUARES MINIMIZATION STAGE %============================================================================================================================================== % this sections uses all the information given before it. The size of arrays etc have to match in order for this to execute successfully. This section needs edited. %Rewritten with c11 = c1, c33 = c2, c44 = c3, c13 = c4, c66 = c5 Vtest = @(c) ( (((Exp_1_3_VT(1)) - (sqrt((((c(1)*(cosd(Refract(1))^2))+(c(2)*(sind(Refract(1))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(1))^2))+(c(2)*(sind(Refract(1))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(1))^2))+(c(3)*(sind(Refract(1))^2)))*((c(3)*(cosd(Refract(1))^2))+(c(2)*(sind(Refract(1))^2)))-(((c(4)+c(3))^2)*(sind(Refract(1))^2)*(cosd(Refract(1))^2))))))/(2*P))... ))^2)... +(((Exp_1_3_VT(2)) - (sqrt((((c(1)*(cosd(Refract(2))^2))+(c(2)*(sind(Refract(2))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(2))^2))+(c(2)*(sind(Refract(2))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(2))^2))+(c(3)*(sind(Refract(2))^2)))*((c(3)*(cosd(Refract(2))^2))+(c(2)*(sind(Refract(2))^2)))-(((c(4)+c(3))^2)*(sind(Refract(2))^2)*(cosd(Refract(2))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(3)) - (sqrt((((c(1)*(cosd(Refract(3))^2))+(c(2)*(sind(Refract(3))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(3))^2))+(c(2)*(sind(Refract(3))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(3))^2))+(c(3)*(sind(Refract(3))^2)))*((c(3)*(cosd(Refract(3))^2))+(c(2)*(sind(Refract(3))^2)))-(((c(4)+c(3))^2)*(sind(Refract(3))^2)*(cosd(Refract(3))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(4)) - (sqrt((((c(1)*(cosd(Refract(4))^2))+(c(2)*(sind(Refract(4))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(4))^2))+(c(2)*(sind(Refract(4))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(4))^2))+(c(3)*(sind(Refract(4))^2)))*((c(3)*(cosd(Refract(4))^2))+(c(2)*(sind(Refract(4))^2)))-(((c(4)+c(3))^2)*(sind(Refract(4))^2)*(cosd(Refract(4))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(5)) - (sqrt((((c(1)*(cosd(Refract(5))^2))+(c(2)*(sind(Refract(5))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(5))^2))+(c(2)*(sind(Refract(5))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(5))^2))+(c(3)*(sind(Refract(5))^2)))*((c(3)*(cosd(Refract(5))^2))+(c(2)*(sind(Refract(5))^2)))-(((c(4)+c(3))^2)*(sind(Refract(5))^2)*(cosd(Refract(5))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(6)) - (sqrt((((c(1)*(cosd(Refract(6))^2))+(c(2)*(sind(Refract(6))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(6))^2))+(c(2)*(sind(Refract(6))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(6))^2))+(c(3)*(sind(Refract(6))^2)))*((c(3)*(cosd(Refract(6))^2))+(c(2)*(sind(Refract(6))^2)))-(((c(4)+c(3))^2)*(sind(Refract(6))^2)*(cosd(Refract(6))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(7)) - (sqrt((((c(1)*(cosd(Refract(7))^2))+(c(2)*(sind(Refract(7))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(7))^2))+(c(2)*(sind(Refract(7))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(7))^2))+(c(3)*(sind(Refract(7))^2)))*((c(3)*(cosd(Refract(7))^2))+(c(2)*(sind(Refract(7))^2)))-(((c(4)+c(3))^2)*(sind(Refract(7))^2)*(cosd(Refract(7))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(8)) - (sqrt((((c(1)*(cosd(Refract(8))^2))+(c(2)*(sind(Refract(8))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(8))^2))+(c(2)*(sind(Refract(8))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(8))^2))+(c(3)*(sind(Refract(8))^2)))*((c(3)*(cosd(Refract(8))^2))+(c(2)*(sind(Refract(8))^2)))-(((c(4)+c(3))^2)*(sind(Refract(8))^2)*(cosd(Refract(8))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(9)) - (sqrt((((c(1)*(cosd(Refract(9))^2))+(c(2)*(sind(Refract(9))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(9))^2))+(c(2)*(sind(Refract(9))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(9))^2))+(c(3)*(sind(Refract(9))^2)))*((c(3)*(cosd(Refract(9))^2))+(c(2)*(sind(Refract(9))^2)))-(((c(4)+c(3))^2)*(sind(Refract(9))^2)*(cosd(Refract(9))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(10)) - (sqrt((((c(1)*(cosd(Refract(10))^2))+(c(2)*(sind(Refract(10))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(10))^2))+(c(2)*(sind(Refract(10))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(10))^2))+(c(3)*(sind(Refract(10))^2)))*((c(3)*(cosd(Refract(10))^2))+(c(2)*(sind(Refract(10))^2)))-(((c(4)+c(3))^2)*(sind(Refract(10))^2)*(cosd(Refract(10))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(11)) - (sqrt((((c(1)*(cosd(Refract(11))^2))+(c(2)*(sind(Refract(11))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(11))^2))+(c(2)*(sind(Refract(11))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(11))^2))+(c(3)*(sind(Refract(11))^2)))*((c(3)*(cosd(Refract(11))^2))+(c(2)*(sind(Refract(11))^2)))-(((c(4)+c(3))^2)*(sind(Refract(11))^2)*(cosd(Refract(11))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(12)) - (sqrt((((c(1)*(cosd(Refract(12))^2))+(c(2)*(sind(Refract(12))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(12))^2))+(c(2)*(sind(Refract(12))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(12))^2))+(c(3)*(sind(Refract(12))^2)))*((c(3)*(cosd(Refract(12))^2))+(c(2)*(sind(Refract(12))^2)))-(((c(4)+c(3))^2)*(sind(Refract(12))^2)*(cosd(Refract(12))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(13)) - (sqrt((((c(1)*(cosd(Refract(13))^2))+(c(2)*(sind(Refract(13))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(13))^2))+(c(2)*(sind(Refract(13))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(13))^2))+(c(3)*(sind(Refract(13))^2)))*((c(3)*(cosd(Refract(13))^2))+(c(2)*(sind(Refract(13))^2)))-(((c(4)+c(3))^2)*(sind(Refract(13))^2)*(cosd(Refract(13))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(14)) - (sqrt((((c(1)*(cosd(Refract(14))^2))+(c(2)*(sind(Refract(14))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(14))^2))+(c(2)*(sind(Refract(14))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(14))^2))+(c(3)*(sind(Refract(14))^2)))*((c(3)*(cosd(Refract(14))^2))+(c(2)*(sind(Refract(14))^2)))-(((c(4)+c(3))^2)*(sind(Refract(14))^2)*(cosd(Refract(14))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VT(15)) - (sqrt((((c(1)*(cosd(Refract(15))^2))+(c(2)*(sind(Refract(15))^2))+c(3)) - sqrt((((c(1)*(cosd(Refract(15))^2))+(c(2)*(sind(Refract(15))^2))+c(3))^2)... -(4*(((c(1)*(cosd(Refract(15))^2))+(c(3)*(sind(Refract(15))^2)))*((c(3)*(cosd(Refract(15))^2))+(c(2)*(sind(Refract(15))^2)))-(((c(4)+c(3))^2)*(sind(Refract(15))^2)*(cosd(Refract(15))^2))))))/(2*P))... ))^2)... + (((Exp_1_2_VL(1))-(sqrt(c(1)/P)))^2)... + (((Exp_1_2_VL(2))-(sqrt(c(1)/P)))^2)... + (((Exp_1_2_VL(3))-(sqrt(c(1)/P)))^2)... + (((Exp_1_2_VL(4))-(sqrt(c(1)/P)))^2)... + (((Exp_1_2_VL(5))-(sqrt(c(1)/P)))^2)... + (((Exp_1_2_VL(6))-(sqrt(c(1)/P)))^2)... + (((Exp_1_2_VL(7))-(sqrt(c(1)/P)))^2)... + (((Exp_1_2_VT(1))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(2))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(3))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(4))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(5))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(6))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(7))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(8))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(9))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(10))-(sqrt(c(5)/P)))^2)... + (((Exp_1_2_VT(11))-(sqrt(c(5)/P)))^2)... + (((Exp_1_3_VL(1)) - (sqrt((((c(1)*(cosd(RefractL(1))^2))+(c(2)*(sind(RefractL(1))^2))+c(3)) + sqrt((((c(1)*(cosd(RefractL(1))^2))+(c(2)*(sind(RefractL(1))^2))+c(3))^2)... -(4*(((c(1)*(cosd(RefractL(1))^2))+(c(3)*(sind(RefractL(1))^2)))*((c(3)*(cosd(RefractL(1))^2))+(c(2)*(sind(RefractL(1))^2)))-(((c(4)+c(3))^2)*(sind(RefractL(1))^2)*(cosd(RefractL(1))^2))))))/(2*P))... ))^2)... + (((Exp_1_3_VL(2)) - (sqrt((((c(1)*(cosd(RefractL(2))^2))+(c(2)*(sind(RefractL(2))^2))+c(3)) + sqrt((((c(1)*(cosd(RefractL(2))^2))+(c(2)*(sind(RefractL(2))^2))+c(3))^2)... -(4*(((c(1)*(cosd(RefractL(2))^2))+(c(3)*(sind(RefractL(2))^2)))*((c(3)*(cosd(RefractL(2))^2))+(c(2)*(sind(RefractL(2))^2)))-(((c(4)+c(3))^2)*(sind(RefractL(2))^2)*(cosd(RefractL(2))^2))))))/(2*P))... ))^2)... ); % + (((Exp_1_3_VL(3)) - (sqrt((((c(1)*(cosd(RefractL(3))^2))+(c(2)*(sind(RefractL(3))^2))+c(3)) + sqrt((((c(1)*(cosd(RefractL(3))^2))+(c(2)*(sind(RefractL(3))^2))+c(3))^2)... % -(4*(((c(1)*(cosd(RefractL(3))^2))+(c(3)*(sind(RefractL(3))^2)))*((c(3)*(cosd(RefractL(3))^2))+(c(2)*(sind(RefractL(3))^2)))-(((c(4)+c(3))^2)*(sind(RefractL(3))^2)*(cosd(RefractL(3))^2))))))/(2*P))... % ))^2)... % + (((Exp_1_3_VL(4)) - (sqrt((((c(1)*(cosd(RefractL(4))^2))+(c(2)*(sind(RefractL(4))^2))+c(3)) + sqrt((((c(1)*(cosd(RefractL(4))^2))+(c(2)*(sind(RefractL(4))^2))+c(3))^2)... % -(4*(((c(1)*(cosd(RefractL(4))^2))+(c(3)*(sind(RefractL(4))^2)))*((c(3)*(cosd(RefractL(4))^2))+(c(1)*(sind(RefractL(4))^2)))-(((c(4)+c(3))^2)*(sind(RefractL(4))^2)*(cosd(RefractL(4))^2))))))/(2*P))... % ))^2)... % ); %================== Fminsearch function ======================================================================================== %This option is another method and may be used to find the local minimums just change the default gradient value and the initial guesses really start to kick in. %c_guess = [6.50e+9, 120.0e+9, 15.0e+9, 3.0e+9, 1.6e+9]; % method to determine all the elastic constants at once %options = optimset('TolFun',1e-5,'MaxFunEvals',1000000000000000000000000,'MaxIter',10000000); % sets up some options for the fminsearch function %[c_min,fval,exitflag,options] = fminunc(Vtest,c_guess,options)% calls the fminsearch function for function vtest and uses c_guess as the initial test paramenters c_guess = [6.50e+9, 100.0e+9, 2.0e+9, 3.0e+9, 1.6e+9]; % method to determine all the elastic constants at once options = optimset('MaxFunEvals',100000000000000000000000000,'MaxIter',1000000000); % sets up some options for the fminsearch function [c_min,fval,exitflag,options] = fminsearch(Vtest, c_guess,options)% calls the fminsearch function for function vtest and uses c_guess as the initial test paramenters %================== End of Fminsearch function ================================================================================= %============================================================================================================================================== % LEAST SQUARES MINIMIZATION STAGE %==============================================================================================================================================