How find the value of V=V0,V1,...,Vn.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
close all
clc
function V=L(Z,r,m,n,u)
Z=2;
n=5;
m=5;
r=0.2;
h=1/m;
% First for loop
for i=0:n
xi=i/n;
% if condition for xi-r
if xi-r< r
lflag=1;
else
j=find(xi-r<Y,1)-1;
alpha=(xi-r-Y(j))/h;
V=Y(j)+alpha*(Y(j+1)-Y(j));
end
% if condition for xi+r
if xi+r>1-r
uflag=1;
else
k=find(xi+r>Y)+1;
alpha=(xi+r-y(k-1))/h;
W=y(k-1)+alpha(Y(k)-Y(k-1));
end
% lflag and uflag conditions for trapz
if lflag == 1 && uflag == 1
w(i+1) = h * trapz(u);
elseif lflag == 1
w(i+1) = h * trapz(u(1:k-1)) + (xi+r-Y(k-1))/2 * (u(k-1) + W);
elseif uflag == 1
w(i+1) = Y(j+1) - (xi-r)/2 * (V + u(j+1)) + h * trapz(u(j+1:end));
else
w(i+1) = Y(j+1) - (xi-r)/2 * (V + u(j+1)) + h * trapz(u(j+1:k-1)) + (xi+r-Y(k-1))/2 * (u(k-1) + W);
end
end
% Another for loop
n=5;
h=1/n;
for i=0:n
V(i+1)=Z/2*h*trapz(w(1:i+1));
end
end
disp(V);
u=u0,u1,...,un are unknown vectors between [0,1]. Y(j)=r+j/m(1-2r), y=y0,y1,...,ym.
2 Kommentare
Antworten (1)
Nipun
am 13 Jun. 2024
Hi Shahid,
I understand that you want to minimize the given expression subject to the constraints. Based on the shared information, I recommend using non-linear minimization option built-in in MATLAB to achieve the desired results.
Here is the link to documentation for "fmincon" function in MATLAB used to find minimum of constrained nonlinear multivariable function: https://www.mathworks.com/help/optim/ug/fmincon.html
Hope this helps.
Regards,
Nipun
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!