matlab fuction maximum and minimum

3 ビュー (過去 30 日間)
Tomas Cyclone
Tomas Cyclone 2020 年 11 月 16 日
コメント済み: Setsuna Yuuki. 2020 年 11 月 16 日
Write a MATLAB function that finds a 2D array and returns the sum of its minimum and maximum values WITHOUT USING "min" and "max" BUILT-IN FUNCTIONS.

採用された回答

Setsuna Yuuki.
Setsuna Yuuki. 2020 年 11 月 16 日
編集済み: Setsuna Yuuki. 2020 年 11 月 16 日
I made a function, I hope help you
a = rand(4); %Example of 2D matrix
b = reshape(a,1,16);
cont = 0; var = zeros(1,length(b));
contM = 0;
for n=1:length(b)
b(n);
for m = 1:length(b)
if(b(n) > b(m))
cont = cont+1;
elseif(b(n)< b(m))
contM = contM+1;
end
if(cont == 15)
maximo = b(n);
elseif (contM == 15)
minimo = b(n);
end
end
var(n) = cont;
cont=0;
contM=0;
end
suma = minimo+maximo;
  2 件のコメント
Tomas Cyclone
Tomas Cyclone 2020 年 11 月 16 日
Thank you so much
Setsuna Yuuki.
Setsuna Yuuki. 2020 年 11 月 16 日
:D

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by