# plotting an equation and finding its max and min

12 Ansichten (letzte 30 Tage)
tyler Wallis am 28 Jan. 2018
Beantwortet: Aman Kumar am 5 Jan. 2021
I would like to plot my function n_sx from 0 to 2*pi and find its max and min over that interval. I know that I can use fplot to plot the function and have done so successfully but I can't find a way to find the max and min using fplot. I've tried plotting my equation using plot but I keep getting errors. Any ideas? thanks
clc;close all
syms z t
E1=15.8;
E2=12.9;
G12=2.7;
v12=0.16;
m=cos(t);
n=sin(t);
y=n_sx==n*m*(m^2*(2+2*v12-E1/G12)+n^2*(-2*v12-2*E1/E2+E1/G12))/(m^4+m^2*n^2*(-2*v12+E1/G12)+n^4*E1/E2)
x=t==linspace(0,2*pi,50);
plot(x,y)
indexmin = find(min(y) == y);
xmin = x(indexmin);
ymin = y(indexmin);
indexmax = find(max(y) == y);
xmax = x(indexmax);
ymax = y(indexmax);
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Nicolas Schmit am 29 Jan. 2018
E1=15.8;
E2=12.9;
G12=2.7;
v12=0.16;
x=linspace(0,2*pi,50);
t = x;
m=cos(t);
n=sin(t);
y=n.*m.*(m.^2.*(2+2.*v12-E1./G12)+n.^2.*(-2.*v12-2.*E1/E2+E1./G12))./(m.^4+m.^2.*n.^2.*(-2.*v12+E1./G12)+n.^4.*E1./E2);
plot(x,y)
indexmin = find(min(y) == y);
xmin = x(indexmin);
ymin = y(indexmin);
indexmax = find(max(y) == y);
xmax = x(indexmax);
ymax = y(indexmax);
##### 1 KommentarKeine anzeigenKeine ausblenden
tyler Wallis am 29 Jan. 2018
Thank you Nicolas!!

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Aman Kumar am 5 Jan. 2021
E1=15.8;
E2=12.9;
G12=2.7;
v12=0.16;
x=linspace(0,2*pi,50);
t = x;
m=cos(t);
n=sin(t);
y=n.*m.*(m.^2.*(2+2.*v12-E1./G12)+n.^2.*(-2.*v12-2.*E1/E2+E1./G12))./(m.^4+m.^2.*n.^2.*(-2.*v12+E1./G12)+n.^4.*E1./E2);
plot(x,y)
indexmin = find(min(y) == y);
xmin = x(indexmin);
ymin = y(indexmin);
indexmax = find(max(y) == y);
xmax = x(indexmax);
ymax = y(indexmax);
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Surface and Mesh Plots in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!