How find the value of V=V0,V1,...,Vn.
Afficher commentaires plus anciens
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.
Réponses (1)
Nipun
le 13 Juin 2024
0 votes
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 commentaire
SHAHID
le 13 Juin 2024
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!