If I use multi funcions with syms variable, How can I get track min value among that funcions?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gookki Jeong
le 1 Août 2020
Commenté : Gookki Jeong
le 6 Août 2020
clear; clc; close all;
syms seta
Rx1= cos(seta)
Rx2= sin(seta)
If I set Rx1, Rx2 funcion like that, How can I get the graph with min value among Rx1, Rx2?
If I use discrete value, I can use like this
xmin=min([R1(x(:)');R2(x(:)');])
plot(x,xmin,'.-');
but, In this case I using Symbolic Math Toolbox, I don't know how I can make it works with syms variable...
0 commentaires
Réponse acceptée
Walter Roberson
le 1 Août 2020
You need to use something like
Min = @(tworows) arrayfun( @(colidx) piecewise(tworows(1,colidx) <= tworows(2,colidx), tworows(1,colidx), tworows(2,colidx)), 1:size(tworows,2);
The code could be simplified if you were willing to use R1 and R2 as separate arguments instead of putting them together in one array.
7 commentaires
Walter Roberson
le 6 Août 2020
close all;
syms seta
gamma = 1;
Rx_ = 1;
Ry_ = Rx_*gamma;
% 등가 정적 적용
gamma = 1;
Rx1= matlabFunction(( cos(seta)-0.3*sin(seta) )*Rx_ ); Rx(1)= "(cos(seta)-0.3 * sin(seta)) * Rx_" ;
Rx2= matlabFunction(( cos(seta)+0.3*sin(seta) )*Rx_); Rx(2)= "(cos(seta)+0.3 * sin(seta)) * Rx_";
Rx3= matlabFunction(( 0.3*cos(seta)-sin(seta) )*Rx_); Rx(3)= "(0.3*cos(seta)-sin(seta)) * Rx_";
Rx4= matlabFunction(( -0.3*cos(seta)-sin(seta) )*Rx_); Rx(4)= "(-0.3*cos(seta)-sin(seta)) * Rx_";
Ry1= (0.3*cos(seta) + sin(seta) )*Ry_; Ry(1)= "(0.3*cos(seta) + sin(seta)) * Ry_";
Ry2= (-0.3*cos(seta) + sin(seta) )*Ry_; Ry(2)= "(-0.3*cos(seta) + sin(seta)) * Ry_";
Ry3= (cos(seta) + 0.3*sin(seta) )*Ry_; Ry(3)= "(cos(seta) + 0.3*sin(seta)) * Ry_";
Ry4= (cos(seta) - 0.3*sin(seta) )*Ry_; Ry(4)= "(cos(seta) - 0.3*sin(seta)) * Ry_";
RR1=@(seta)cos(seta).*(1.3e+1./1.0e+1)+sin(seta).*(7.0./1.0e+1);
RR2=@(seta)cos(seta).*(7.0./1.0e+1)+sin(seta).*(1.3e+1./1.0e+1);
RR3=@(seta)cos(seta).*(1.3e+1./1.0e+1)-sin(seta).*(7.0./1.0e+1);
RR4=@(seta)cos(seta).*(1.3e+1./1.0e+1)-sin(seta).*(7.0./1.0e+1);
a1=fminbnd(RR1,0,2*pi);
b1=fminbnd(@(seta)-RR1(seta),0,2*pi);
a2=fminbnd(RR2,0,2*pi);
b2=fminbnd(@(seta)-RR2(seta),0,2*pi);
a3=fminbnd(RR3,0,2*pi);
b3=fminbnd(@(seta)-RR3(seta),0,2*pi);
a4=fminbnd(RR4,0,2*pi);
b4=fminbnd(@(seta)-RR4(seta),0,2*pi);
% % 위에 반복문의 기준이 된 코드::
subplot(4,1,1);
fplot(Rx1,[0 2*pi]); hold on
fplot(Ry1,[0 2*pi]); hold on
fplot(RR1,[0 2*pi]);
plot(a1,RR1(a1),'*');
plot(b1,RR1(b1),'*');
a="(" + num2str(round(a1/pi,2))+"pi [" + num2str(round(a1/pi*180,2))+"\circ]";
a_= " , " + num2str(round(RR1(a1),2))+")";
a= a + a_;
b="(" + num2str(round(b1/pi,2))+"pi [" + num2str(round(b1/pi*180,2))+"\circ]";
b_= " , " + num2str(round(RR1(b1),2))+")";
b= b + b_;
xticks([0 0.5*pi pi 1.5*pi 2*pi])
xticklabels({'0','0.5\pi','\pi','1.5\pi','2\pi'})
legend('x축','y축',"단순합",a,b,'location','best')
subplot(4,1,2);
fplot(Rx2,[0 2*pi]); hold on
fplot(Ry2,[0 2*pi]); hold on
fplot(RR2,[0 2*pi]);
plot(a2,RR2(a2),'*');
plot(b2,RR2(b2),'*');
a="(" + num2str(round(a2/pi,2))+"pi [" + num2str(round(a2/pi*180,2))+"\circ]";
a_= " , " + num2str(round(RR2(a2),2))+")";
a= a + a_;
b="(" + num2str(round(b2/pi,2))+"pi [" + num2str(round(b2/pi*180,2))+"\circ]";
b_= " , " + num2str(round(RR2(b2),2))+")";
b= b + b_;
xticks([0 0.5*pi pi 1.5*pi 2*pi])
xticklabels({'0','0.5\pi','\pi','1.5\pi','2\pi'})
legend('x축','y축',"단순합",a,b,'location','best')
MIN2 = @(v1, v2) piecewise(v1 <= v2, v1, v2);
MIN4 = @(v1, v2, v3, v4) MIN2(MIN2(v1,v2),MIN2(v3,v4));
R1 = RR1(seta);
R2 = RR2(seta);
R3 = RR3(seta);
R4 = RR4(seta);
RR1234 = MIN4(R1,R2,R3,R4);
figure
fplot(RR1234, [0 2*pi])
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!