フィルターのクリア

why is my code not working?

2 ビュー (過去 30 日間)
Anjoud Alkathairi
Anjoud Alkathairi 2022 年 11 月 14 日
コメント済み: Anjoud Alkathairi 2022 年 11 月 14 日
v=[2;0;1;9;0;1;3;0;1];
m=max(v);
n=mean(v);
f=@(x) m-(1/2)*x;
g=@(x) 2*x^2-n;
figure
ezplot(f);
hold on
ezplot(g);
hold on
syms x y
eqns=y==m-(1/2)*x;y=2*x^2-n;
[solx, soly]=solve(eqns,[x y]);
plot(solx(1),soly(1),'b-x',solx(2),soly(2),'b-x')
expr1=m-(1/2)*x;
expr2=2*x^2-n;
I1=int(expr1,[solx(1) solx(2)]);
I2=int(expr2,[solx(1) solx(2)]);
I=I2-I1;
fprintf('The area bounded by the two curves is: %f\n',I);

回答 (1 件)

Stephan
Stephan 2022 年 11 月 14 日
v=[2;0;1;9;0;1;3;0;1];
m=max(v);
n=mean(v);
f=@(x) m-(1/2).*x; % Vectorized
g=@(x) 2.*x.^2-n; % Vectorized
figure
ezplot(f);
hold on
ezplot(g);
hold on
syms x y
eqns=[y==m-(1/2)*x;y==2*x^2-n]; % Array and y==2 instead of y=2 in equation 2
[solx, soly]=solve(eqns,[x y]);
plot(solx(1),soly(1),'b-x',solx(2),soly(2),'b-x')
expr1=m-(1/2)*x;
expr2=2*x^2-n;
I1=int(expr1,[solx(1) solx(2)]);
I2=int(expr2,[solx(1) solx(2)]);
I=I2-I1;
fprintf('The area bounded by the two curves is: %f\n',I);
The area bounded by the two curves is: 34.022481
  1 件のコメント
Anjoud Alkathairi
Anjoud Alkathairi 2022 年 11 月 14 日
Thank you so much

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by