optimising variables that are dependent on other variables
11 次查看(过去 30 天)
显示 更早的评论
I am trying to find best coordinates and angle of inclination of line that would give me the least sum of distance between stationary curve and a line.
The curve position remains fixed but the coordinates of line can change and lines inclination can change giving me the best position of line that will give me the least sum of distance (objective function)
Can anyone suggest or hint how to use inbuilt optimization function provided in matlab to approach this problem. This is a multi variable optimization problem where we need to find best value of x,y, theta.
Diagram and constraints are given below to understand problem. The concept will help me in my research work. I have written the code as well to provide initial position of line and curve and inclination of line but I donot understand how to use inbuilt function here directly since variables of objective funtion are dependent on other variables.
Example that shows initial position and next iteration
Constraints and problem defination
code for position staionary curve and initial position of line
clc,clear
r = 40; % arc length
R = 55; % radius of a circle
aa = 60*pi/180; % arc angle
ap = 0*pi/180; % arc position angle
t1 = linspace(0,aa)-aa/2+ap;
[x1,y1] = pol2cart(t1,r); % arc data
xcen=60;
ycen=10;
%Shifting arc lower end to (60,10) (stationary arc)
delx=xcen-x1(1);
dely=ycen-y1(1);
x1=x1+delx;
y1=y1+dely;
% defining the line with one end at (14,15)
L = linspace(0,10); % line segment lenth max is 5 and min is 0
theta = 60*pi/180; % initial angle of inclination
% starting point at (14,15)
x0=14;
y0=15;
x=x0+ L* cos(theta);
y=y0+L * sin(theta);
% for highlighting point at distance of L/4 from both ends
ind= [25 75];
x1_h=x(ind);
y1_h=y(ind);
plot (x1,y1)
hold on
plot(x,y)
0 个评论
采纳的回答
Jon
2020-11-19
If you have the optimization toolbox then you can use fmincon to solve this type of problem. https://www.mathworks.com/help/optim/ug/fmincon.html
You will need to write a function, in your case may not be simple, that in the end will give you values of your objective function Z as a function of xa, ya, and theta.
13 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!