how do i find the min value using for loop?
2 views (last 30 days)
Show older comments
lakshmi sampath reddy Pulagum
on 28 Nov 2021
Commented: lakshmi sampath reddy Pulagum
on 29 Nov 2021
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)
0 Comments
Accepted Answer
Chunru
on 28 Nov 2021
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
8 Comments
Chunru
on 29 Nov 2021
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
More Answers (1)
See Also
Categories
Find more on Assumptions 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!