clc
clear all
%read in text data
D=readmatrix('Treloar_data.xlsx');
stretch=D(1:end,1); %this is lambda
lambda=stretch;
stress=D(1:end,2); %this is stress
T_0=stress;
u=.5673; %small strain shear modulus, mu
%constrained
fun=@(x)(2*(lambda-lambda.^-2).*(x(1)+(lambda.^-1).*x(2))-T_0);
x0=[-100000,100000]; %initial guess
%constraints
% A=2*(c(1)+c(2))==u this is the constraint i want to use
lb=[0,0]
ub=[10,10]
x=lsqnonlin(fun,x0,lb,ub);
c(1)=x(1)
c(2)=x(2)
T_MR=2*(lambda-lambda.^-2).*(c(1)+(lambda.^-1).*c(2));
figure
plot(lambda, T_0,'o'), xlabel('stretch'), ylabel('stress'), title('UT')
hold on
plot(lambda, T_MR)
i want to employ a constraint that involves both constants if possible as labeled

 채택된 답변

Torsten
Torsten 2023년 4월 6일
편집: Torsten 2023년 4월 6일

0 개 추천

% A=2*(c(1)+c(2))==u this is the constraint i want to use
Then optimize with one parameter c(1) and insert c(2) = u/2 - c(1) for the second parameter in your model function.
And if you want the solution to be in [0 10], why do you supply an initial guess of -100000 and 100000 ?

댓글 수: 3

John D'Errico
John D'Errico 2023년 4월 6일
There are bounds of 0 and 10 on both variables. However, if you use the "constraint" to eliminate one of the variables, With that value of u though, consider what MAY happen.
u=.5673;
If you use this to eleminate one of the unknowns using this constraint,
2*(c(1) + c(2)) = u
so then we will have
c(1) = u/2 - c(2)
But c(2) can be any number within 0 and 10. And that means if c(2) is greater than u/2, so roughly 0.28, then c(1) will be negative. And that would fail the bound constraints.
So you CANNOT use this trick to eliminate one unknown.
Torsten
Torsten 2023년 4월 7일
Because of the constraint 2*(c(1)+c(2))==u, one can set lb = 0 and ub = u/2 for c(1) (note here that the lower bound for c(2) is also 0). Then I think one can proceed as suggested.
John D'Errico
John D'Errico 2023년 4월 7일
Yes. That will suffice.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jon
Jon 2023년 4월 6일

0 개 추천

From my understanding lsqnonlin only allows for bound constraints on the components of x. For more general problems you will have to use fmincon

댓글 수: 1

Jon
Jon 2023년 4월 6일
I didn't look at the details of your constraint. I would follow @Torsten's suggestion to see if you can in fact simplify the problem to eliminate the additional constraint.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Stress and Strain에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2023년 4월 6일

댓글:

2023년 4월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by