clc
clear all
syms x
for yr = linspace(0,1,10)
f = sin(x);
fL = [0 pi];
iL = [0 pi];
Volume = pi*int((f-yr)^2,iL(1),iL(2));
s=double(Volume)
end
h=min(s)

 採用された回答

Chunru
Chunru 2021 年 11 月 28 日

0 投票

syms x
smin = inf; % initialize smin
for yr = linspace(0,1,10)
f = sin(x);
fL = [0 pi];
iL = [0 pi];
Volume = pi*int((f-yr)^2,iL(1),iL(2));
s=double(Volume);
if s<smin,
smin = s;
end
end
%h=min(s)
smin
smin = 0.9437

8 件のコメント

lakshmi sampath reddy Pulagum
lakshmi sampath reddy Pulagum 2021 年 11 月 28 日
I could not understand it why have you choosen infinity as smin? Can you please explain?
Chunru
Chunru 2021 年 11 月 28 日
編集済み: Chunru 2021 年 11 月 28 日
You put a very large value as the initial value to ensure that the min is from the data. You can go through a simple example of s = -10, -100, 200, 1000 and examine what happens with:
smin = inf
for s = [-10, -100, 200, 1000]
if s<smin,
smin = s;
end
end
lakshmi sampath reddy Pulagum
lakshmi sampath reddy Pulagum 2021 年 11 月 28 日
thank you so much.now i could understand it.its a good logic.once again thank you.
lakshmi sampath reddy Pulagum
lakshmi sampath reddy Pulagum 2021 年 11 月 28 日
and how can i find the point at which it is minimum
lakshmi sampath reddy Pulagum
lakshmi sampath reddy Pulagum 2021 年 11 月 28 日
clc
clear all
syms x
smin = inf; % initialize smin
for yr = linspace(0,1,10)
f = sin(x);
fL = [0 pi];
iL = [0 pi];
Volume = pi*int((f-yr)^2,iL(1),iL(2));
s=double(Volume);
if s<smin,
smin = s;
end
end
smin
for yr = linspace(0,1,10)
f = sin(x);
fL = [0 pi];
iL = [0 pi];
Volume = pi*int((f-yr)^2,iL(1),iL(2));
h=double(Volume)
if smin==h for yr= linspace(0,1,10);
disp(yr)
end
end
end
lakshmi sampath reddy Pulagum
lakshmi sampath reddy Pulagum 2021 年 11 月 28 日
i have tried this one but this doesnt make any sense can you help
Chunru
Chunru 2021 年 11 月 29 日
syms x
smin = inf; % initialize smin
locmin = nan;
for yr = linspace(0,1,10)
f = sin(x);
fL = [0 pi];
iL = [0 pi];
Volume = pi*int((f-yr)^2,iL(1),iL(2));
s=double(Volume);
if s<smin,
smin = s;
locmin = yr;
end
end
smin, yr
smin = 0.9437
yr = 1
lakshmi sampath reddy Pulagum
lakshmi sampath reddy Pulagum 2021 年 11 月 29 日
ahh it is wrong.its taking yr=1 for max and min too.can you please check it.

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

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by