I am writing a code for using "fmincon" but it is having some error, Why?
Mostra commenti meno recenti
I am writing the following code. I am not able to find the error? I am new to MATLAB.
dbstop if error
clear all
clc
format longEng
kv = 0.5; kh = 0.1;
r0 = 5; H = 5;
q = 20; a = 1;
b = 0; gamma = 18.4;
omega = 25; phi = 39*(pi/180);
lambda = kv/kh;
syms x(i)
% fun = @(x)A1 /((lambda*A1)+A2)
L = r0*(sin(x(2))*exp((x(2)-x(1))*tan(phi))-sin(x(1)))
% % % % Rate of work due to soil weight in static condition
f1 = -(1/3)*(1/(9*((tan(phi))^2)+1)*(exp(3*(x(2) - x(1))*tan(phi))*(3*tan(phi)*sin(x(2))-cos(x(2)))-(3*tan(phi)*sin(x(1))-cos(x(1)))))
f2 = -(1/6)*(L/r0)*cos(x(2))*exp(x(2)-x(1))*tan(phi)*(2*sin(x(1))+(L/r0))
f3 = -(1/3)*(H/r0)*(sin(x(1)))^2
W1 = (1-kv)*gamma*omega*((r0)^3)*(f1-f2-f3)
% Rate of work due to strip load
Wqs = -(1-kv)*omega*q*b*(a+(b/2)+r0*sin(x(1)))
% % % % Rate of work due to soil weight with kh
fq1 = -(1/3)*(1/(9*((tan(phi))^2)+1)*(exp(3*(x(2) - x(1))*tan(phi))*(3*tan(phi)*cos(x(2))+sin(x(2)))-(3*tan(phi)*cos(x(1))+sin(x(1)))))
fq2 = -(1/3)*(L/(r0)^2)*cos(x(2))*exp(x(2)-x(1))*tan(phi)*(cos(x(1))-(H/r0))
fq3 = -(1/6)*(H/r0)*sin(x(1))*(2*cos(x(1))-(H/r0))
W1kh = kh*gamma*omega*((r0)^3)*(fq1-fq2-fq3)
% Rate of work due to strip load
Wqskh = -kh*omega*q*b*r0*exp((x(2)-x(1))*tan(phi))*cos(x(2))
% Yield acceleration coefficients (ky)
A1 = gamma*omega*((r0)^3)*(f1-f2-f3) - omega*q*b*(a+(b/2)+r0*sin(x(1)))
A2 = omega*q*b*r0*exp((x(2)-x(1))*tan(phi))*cos(x(2)) - gamma*omega*((r0)^3)*(fq1-fq2-fq3)
fun = @(x)A1 /((lambda*A1)+A2)
lb = [0,0];
ub = [3.14,3.14];
A = [];
b = [];
Aeq = [];
beq = [];
x0 = [0,0];
nonlcon = [];
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
1 Commento
Matt J
il 13 Mag 2022
What error messages (copy/pasted) is it giving you?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Nonlinear Optimization in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!