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 7521689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:17:59+00:00 2026-05-30T02:17:59+00:00

I am new to matlab, I have a column vector with binary values I

  • 0

I am new to matlab, I have a column vector with binary values
I want to get the indices where the value changes from 0 to 1, and the indices when there is a change from 1 to 0.

This is my first question to Stackoverflow so am hoping to get the needed help,
Thank you in advance.

  • 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-05-30T02:18:01+00:00Added an answer on May 30, 2026 at 2:18 am

    Use diff with find.

    x = rand(1, 10) > 0.5
    
    % all changes
    find(diff(x)) + 1
    
    % 0 to 1 and 0 to 1 separately
    find(diff(x) == 1) + 1
    find(diff(x) == -1) + 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to MATLAB. Suppose I have a vector like x = [1
I'm new to python, coming from matlab. I have a large sparse matrix saved
I have a Binary classification problem that I need to do in MATLAB. There
I'm completely new to MATLAB and I want to know what my options are
I'm new to MATLAB and mrVista. I'm running Matlab Version 7.8.0.347 (R2009a) 32-bit(win32) from
In MATLAB, when you click File -> New -> Function M-File, you get a
I am new to Matlab and have difficulty understanding global variables. For example global
I'm new to matlab classes and have just gone through a couple tutorials and
I am fairly new to Matlab and have a few questions. I got two
I am very new to matlab and image processing toolbox. I have a source

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.