Ask Question
20 May, 23:45

3. mydetecttop (f, a, t) which takes three inputs: [50 pts] f: A function handle. a: A real number. t: A real number. Note: You may assume that f is increasing at x = a but there is a cutoff x = b > a after which f starts decreasing. Does: Uses a while loop to check f (x) for x = a, x = a + 3t, x = a + 6t, ... until a value is smaller than the previous value. Returns: The x value (not the f (x) value!) for which this happens

+3
Answers (1)
  1. 21 May, 03:17
    0
    function n = mydetecttop (f, a, t)

    n = a;

    value1 = f (n);

    i1 = 4;

    while (true)

    n = a + i1*t;

    value2 = f (n);

    if (value2 < value1)

    break

    end

    value1 = value2;

    i1 = i1 + 4;

    end

    end

    function t = atc (n)

    if (n<25)

    t = n + 1;

    else

    t = 0 - n;

    end

    end

    f = @atc;

    n = mydetecttop (f, 1, 2)

    Explanation:

    Run a while loop until the required value is found and update the value of the variable n. Check if value2 is less than value1 and then break out of the loop. Update the value of the variable i1 by adding 4. Finally test the mydetecttop (f, a, t) function.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “3. mydetecttop (f, a, t) which takes three inputs: [50 pts] f: A function handle. a: A real number. t: A real number. Note: You may assume ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers