write max mean as an alternative

6 Ansichten (letzte 30 Tage)
Ugur Sahin
Ugur Sahin am 7 Apr. 2020
Kommentiert: Ugur Sahin am 7 Apr. 2020
Hi guys,
I am trying to write max() and min but our teacher said you cannot use max() and min() function. how can ı write alternativly these functions. I have done mean value like that:
if length(m)==4
element=element+1;
s =sum(m) / 4;
arc = [arc s];
m=[];
end
every 4 step m function reset and also values that have been in m (m has 4 element at the moment) sums and divide 4. the new value (mean value of a at the moment) goes arc.
I want to da that max and min version without max and min command but this time the values has to go new set that ı called maxvalues and min values could someone help me ?
  3 Kommentare
Ugur Sahin
Ugur Sahin am 7 Apr. 2020
https://imgur.com/a/wjWhlTQ
Image Analyst
Image Analyst am 7 Apr. 2020
Ugur, post the image directly here with the green and brown frame icon, not on some third party web site.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

David Hill
David Hill am 7 Apr. 2020
a=sort(x)
maxvalue=a(end);
minvalue=a(1);
  3 Kommentare
David Hill
David Hill am 7 Apr. 2020
maxvalue=x(1);
minvalue=x(1);
for k=2:length(x)
if x(k)>maxvalue
maxvalue=x(k);
elseif x(k)<minvalue
minvalue=x(k);
end
end
Ugur Sahin
Ugur Sahin am 7 Apr. 2020
thank you so much :D

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Identification 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!

Translated by