How find the value of V=V0,V1,...,Vn.

2 ビュー (過去 30 日間)
SHAHID
SHAHID 2024 年 6 月 12 日
コメント済み: SHAHID 2024 年 6 月 13 日
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 件のコメント
Aquatris
Aquatris 2024 年 6 月 12 日
What exactly is the question?
SHAHID
SHAHID 2024 年 6 月 12 日
I want to minimize this function.

サインインしてコメントする。

回答 (1 件)

Nipun
Nipun 2024 年 6 月 13 日
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
  1 件のコメント
SHAHID
SHAHID 2024 年 6 月 13 日
Dear Sir, can you give suggestion for writing code with fmincon because its new for me. I will wait your response. Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by