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

  • Home
  • SEARCH
  • 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 8889261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:13:06+00:00 2026-06-14T22:13:06+00:00

Hi I need some help with matlab. I have a matrix that’s 500 x

  • 0

Hi I need some help with matlab.

I have a matrix that’s 500 x 360. Below is a sample data set:

10 10 12 11 9 8 8 25 26 26 20 20 20 
20 22 26 20 20 19 30 31 33 35 33 32
30 30 29 31 32 33 31 33 33 32 31 31
40 50 49 45 47 47 45 65 68 69 70 71

The code has to perform the following:

  1. Finds the first occurrence of a value I specify, in this case is a change of 20%. So observing (1,:), the first occurrence of a change of 20% is between column 2 and 3.
  2. Then it identifies the lowest value that occurred after the value specified in step 1. In this case is column 6 (i.e., value of 8). The code then measures the time elapsed from the value specified in step 1 to the lowest value that occurred in step 2. Looking back at the example, delta of 20% is (1,3) = 12, lowest value occurred after delta 20% is (1,6) = 8. Elapsed time is 3.
  3. The code then finds the highest value from the lowest value found in step 2. In this case is column 9 with a value of 26. It also records the time elapsed.
  4. Lastly, the code measure the time elapsed from the first delta value to the highest value found. In this case is the time from (1,3) to (1,9) which is 6.

So the output would look something like this:

12  8   3   26  3   6
26  19  3   35  4   3
NaN NaN NaN NaN NaN NaN
50  45  2   71  8   10

I appreciate your help. Thanks so much:)

  • 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-14T22:13:07+00:00Added an answer on June 14, 2026 at 10:13 pm

    I do not have access to matlab right now. But here are some steps to get you started.
    Do double check the answers for your test case to see you get desired result.

    Say you have a row vector x. In your case say the ith row of your data matrix i.e. x = data(i,:);

    Now to find the first occurrence of (say) 20% change you can use:

    cI = find( x >= x(1)*1.2, 1, 'first' );
    

    where cI will be the index of first value greater than 20% change and x(cI) is the required value.

    next to find the minimum after this value use

    [minV, minI] = min(x( (cI+1):end ));
    

    and to find the maximum after that:

    [maxV, maxI] = max(x( (cI+minI+1):end ));
    

    finally to put all together:

    [x(cI), minV, minI, maxV, maxI, (minI + maxI)]
    

    This will work for your first row. Now for the third row you will need to make sure cI has a value. If cI is empty then just use NaN(1,6).

    There will be similar error check if cI+1 or cI+minI+1 exceed the number of elements. This will happen if the change you are looking for happens too late.

    For start you can set up a for-loop over each row (i), but there has to be a better way to vectorize the code.

    Whole thing set up as using a for-loop

    % I have used generic variable names. Change them to something meaningful.
    data = rand(500,360); % Use your data
    change = 0.2;   % or 20/100 if you prefer percentage
    [nROWS, nCOLS] = size(data);
    result = NaN( nROWS, 6); % Defining it this way saves the trouble to having to assign NaNs
    
    for row = 1:nROWS
        x = data( row, : );   % Not required, but easy to write code
    
        cI = find( x >= x(1)*(1+change), 1, 'first' );
        if isempty(cI)
            continue;
        end
        if cI == nCOLS  % no more elements to find min and max from
            result(row, 1) = x(cI);
            continue;
        end
    
        [minV, minI] = min(x( (cI+1):end ));
        if (cI + minI) == nCOLS % no more elements to find max from
            result(row, 1:3) = [x(cI), minV, minI];
        end
    
        [maxV, maxI] = max(x( (cI+minI+1):end ));
        result(row, :) = [x(cI), minV, minI, maxV, maxI, (minI + maxI)];
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help in this problem I have this matrix in MATLAB: A
Need some help with DataFormatString in GridView. I have a Double value that needs
Need some help, I have a regular expression that appears to work just fine
Need some help with below issue We have 2 machines, each of these machines
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help to solve this. I have a gridview and inside the gridview
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help assigning a mouseover event to display some icons that start out
Need some help with a query.. I have three tables. Source id name 1

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.