Non Linear Optimization using Fmincon
Show older comments
Hello,
I am trying to do nonlinear optimization using fmincon in matlab. I don't have much experience with this specific topic and was curious if anyone could help me implement this into matlab.
I have to minimize -ls1 subject to lc1-1=0, lc2-1=0,... lc9-1=0, ls2-ls1=0, ls3-ls1=0.
I have equations to calculate all of these values and can change the values r and theta. Any help at all would be appreciated I have hit a brick wall on this problem
r = 1; % Define the radius
adjust = 25; % Adjust the twist angle
height =1; % Define the height
theta1 = linspace(90,330,3); % Bottom theta values
theta2 = linspace(theta1(1)+adjust,theta1(end)+adjust,3); % Top theta values
theta = [theta1,theta2]; % Combine for ease of use
M_Ls1 = height^2+2*r^2*(1-(cosd(theta(1))*cosd(theta(5)))-(sind(theta(1))*sind(theta(5))));
M_Ls2 = height^2+2*r^2*(1-(cosd(theta(2))*cosd(theta(6)))-(sind(theta(2))*sind(theta(6))));
M_Ls3 = height^2+2*r^2*(1-(cosd(theta(3))*cosd(theta(4)))-(sind(theta(3))*sind(theta(4))));
M_Lc1 = 2*r^2*(1-(cosd(theta(1))*cosd(theta(2)))-(sind(theta(1))*sind(theta(2))));
M_Lc2 = 2*r^2*(1-(cosd(theta(1))*cosd(theta(3)))-(sind(theta(1))*sind(theta(3))));
M_Lc3 = height^2 + 2*r^2*(1-(cosd(theta(1))*cosd(theta(4)))-(sind(theta(1))*sind(theta(4))));
M_Lc4 = 2*r^2*(1-(cosd(theta(2))*cosd(theta(3)))-(sind(theta(2))*sind(theta(3))));
M_Lc5 = height^2 + 2*r^2*(1-(cosd(theta(2))*cosd(theta(5)))-(sind(theta(2))*sind(theta(5))));
M_Lc6 = height^2 + 2*r^2*(1-(cosd(theta(3))*cosd(theta(6)))-(sind(theta(3))*sind(theta(6))));
M_Lc7 = 2*r^2*(1-(cosd(theta(4))*cosd(theta(5)))-(sind(theta(4))*sind(theta(5))));
M_Lc8 = 2*r^2*(1-(cosd(theta(4))*cosd(theta(6)))-(sind(theta(4))*sind(theta(6))));
M_Lc9 = 2*r^2*(1-(cosd(theta(5))*cosd(theta(6)))-(sind(theta(5))*sind(theta(6))));
1 Comment
Divija Aleti
on 4 Dec 2020
Hi,
Can I know with respect to what variable you want to minimize -ls1 ? Also, what do you mean by 'the values of r and theta can be changed?'
Answers (0)
Categories
Find more on Nonlinear Control in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!