how do i find the min value using for loop?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
lakshmi sampath reddy Pulagum
am 28 Nov. 2021
Kommentiert: lakshmi sampath reddy Pulagum
am 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 Kommentare
Akzeptierte Antwort
Chunru
am 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 Kommentare
Chunru
am 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
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!