I need to find the max value of an Array without using builtin functions

조회 수: 2 (최근 30일)
Kamie Hopper
Kamie Hopper 2015년 2월 12일
편집: Image Analyst 2015년 2월 14일
Write out by hand a MATLAB script for finding the maximum value within an array, A. Assume the array is given and you can calculate the size of the array using the MATLAB command size. You cannot use any other MATLAB built-in functions, including max.
I don't even know how to start this process. Not asking for the assignment to be done for me. Just some tips or hints. Thanks
  댓글 수: 3
Stephen23
Stephen23 2015년 2월 12일
편집: Stephen23 2015년 2월 12일
"Write out by hand a MATLAB script..."
By hand !?!?
Star Strider
Star Strider 2015년 2월 12일
It’s been a very long while since I wrote in assembler, but if I remember correctly, even machine code has relational and conditional operators. Barring all of them at any level makes this assignment absolutely impossible.

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2015년 2월 12일
Relational operators such as < or <= and others might be useful. Since you’re allowed to use size, read the documentation on for and if as well.
  댓글 수: 2
Kamie Hopper
Kamie Hopper 2015년 2월 13일
편집: Image Analyst 2015년 2월 14일
I finally got it. And I used
a=(blah)
[m,n]= size(a)
For I=1:1:m
For j=1:1:n
If blah
. X=max
. Else stuff
And went from there. It's too hard to respond from my phone. But thanks for the correct answer!. And yes we do a lot of code by hand. It has been helpful.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by