Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:27:25+00:00 2026-06-07T23:27:25+00:00

a=[2 3 6 7 2 1 0.01 6 8 10 12 15 18 9

  • 0
a=[2 3 6 7 2 1 0.01 6 8 10 12 15 18 9 6 5 4 2].

Here is an array i need to extract the exact values where the increasing and decreasing trend starts.

the output for the array a will be [2(first element) 2 6 9]

a=[2 3 6 7 2 1 0.01 6 8 10 12 15 18 9 6 5 4 2].
   ^       ^        ^               ^
   |       |        |               |

Kindly help me to get the result in MATLAB for any similar type of array..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:27:27+00:00Added an answer on June 7, 2026 at 11:27 pm

    This is a great place to use the diff function.

    Your first step will be to do the following:
    B = [0 diff(a)]

    The reason we add the 0 there is to keep the matrix the same length because of the way the diff function works. It will start with the first element in the matrix and then report the difference between that and the next element. There’s no leading element before the first one so is just truncates the matrix by one element. We add a zero because there is no change there as it’s the starting element.

    If you look at the results in B now it is quite obvious where the inflection points are (where you go from positive to negative numbers).

    To pull this out programatically there are a number of things you can do. I tend to use a little multiplication and the find command.

    Result = find(B(1:end-1).*B(2:end)<0)

    This will return the index where you are on the cusp of the inflection. In this case it will be:

    ans =
    
         4     7    13
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to extract Asia from this array. How can i do that. Here
I need to add values received from MySQL into an array (PHP). Here is
I need to build a multidimensional array from records retrieved from my database. Here
I need to extract a value from a process array to myArray: File: MyClass.vb
I've got this array (shortened for this question), and I need to extract the
Here's my array and i need to do a foreach to display the image
So i have a class name repository which is just a simple array.Here is
if($err) $_SESSION['msg']['login-err'] = implode('<br />',$err); Three quick questions: Why use a two-dimensional array here?
$.getJSON(./data/revenue-item-data.php,{val:'val'},function(data){ $('#totalUnits').val(data[0].SUM(item_qty)); $('#totalAmounts').val(data[0].SUM(DISTINCT net_total)); }); Here is array I get for above code: [{SUM(item_qty):68,SUM(DISTINCT
Here is my array that is put together: Array ( [1] => Array (

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.