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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:10:14+00:00 2026-06-10T07:10:14+00:00

I have this vector: t = 1: 10 % t = 1 2 3

  • 0

I have this vector:

t = 1: 10 % t = 1 2 3 ..10

A= [3 4 5] % a column vector 

If I type:

(3 == t)

I get the result:

0 0 1 0 0 0 0 0 0 0 % it means: 1 at location equals, and 0 at others

I want to do this for vector a, meaning that it will take each element in vector A and compare and return another vector. So in this case, the result will be a 3×10 matrix.

But this line will result in an error: A==t.

Of course, I can do this by using a for loop, but I want to vectorize this operation.

  • 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-10T07:10:16+00:00Added an answer on June 10, 2026 at 7:10 am

    what you are looking for is the function ismember

    octave> t = 1:10
    t =
        1    2    3    4    5    6    7    8    9   10
    
    octave> A = ismember (t, [2 3 4])
    A =
       0   1   1   1   0   0   0   0   0   0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the vector d<-1:100 I want to sample k=3 times from this vector
I have a large nested vector that look like this: import Data.Vector let x
I have a vector in R that looks like this: dat <- c(TRUE, TRUE,
Say I have a vector: (def data [Hello World Test This]) And I want
I have a vector, v3, that looks like this: v3 <- matrix(c(1,1,3,3,2,2, 2,3,1,2,3,1, 3,2,2,1,1,3),
I have this recommendations table: Table public.recommendations Column | Type | Modifiers -----------------------+-----------------------------+-------------------------------------------------------------- id
I have a column vector that needs to be changed into a matrix. The
I have a function that processes a row vector. I want to make it
I have a column vector I want to convert to a cell array such
Basically i have a function that returns a column vector of size Z(100,1) of

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.