How can I get maximum and minimum value with sym variables

11 次查看(过去 30 天)
clear; clc; close all;
syms seta
gamma = 1;
Rx_ = 1;
Ry_ = Rx_*gamma;
% 등가 정적 적용
gamma = 1;
Rx1= ( cos(seta)-0.3*sin(seta) )*Rx_ ;
Rx2= ( cos(seta)+0.3*sin(seta) )*Rx_;
Rx3= ( 0.3*cos(seta)-sin(seta) )*Rx_;
Rx4= ( -0.3*cos(seta)-sin(seta) )*Rx_;
Ry1= (0.3*cos(seta) + sin(seta) )*Ry_;
Ry2= (-0.3*cos(seta) + sin(seta) )*Ry_;
Ry3= (cos(seta) + 0.3*sin(seta) )*Ry_;
Ry4= (cos(seta) - 0.3*sin(seta) )*Ry_;
N=4;
for ii=1:N
temp=['RR',num2str(ii),'=Rx',num2str(ii),'+Ry',num2str(ii),';'];
eval(temp);
end
here is my code, then I get
RR1 =
(13*cos(seta))/10 + (7*sin(seta))/10
RR2 =
(7*cos(seta))/10 + (13*sin(seta))/10
etc.
and now I want to get the max and min value and seta value at that point. but I don't know how I get it. the max(), min() didn't work for syms funtion.

采纳的回答

madhan ravi
madhan ravi 2020-7-30
Use matlabFunction() and fminbnd() to find the minimum value of that function and to find the maximum extreme use negative sign for the function and feed it to fminbnd().
doc matlabFunction
doc fminbnd
And as always eval() here is completely not necessary and should be avoided.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by