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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:32:49+00:00 2026-05-31T05:32:49+00:00

The output vector should look like : a=[3 3 3 4 4 4 4

  • 0

The output vector should look like :

a=[3 3 3 4 4 4 4 5 5 5 5 5]

What i have is:

pe=[1 5 9] and ne=[4 8 12] and co=[3 4 5]

pe describes the starting index and ne the ending index from each entry and co the value of this entry

I want do this without loop.
With Loop it should look like this:

  for i=1:3
     a(pe(i):ne(i))=co(i)
   end
  • 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-31T05:32:50+00:00Added an answer on May 31, 2026 at 5:32 am

    One way to do this is to create an array of indices into co first, using cumsum

    idxList = zeros(1,max(ne)); %# create an array with zeros
    idxList(pe) = 1;            %# mark the start of a new index
    idxList = cumsum(idxList);  %# now, idxList has 1's where we should
                                %# place the first element of co, etc
    out = co(idxList);          %# and we're done. 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vector like this : Sum<-c(24, 32, 40, 48, 56, 28, 36,
Actually I have millions of vector objects in my program. In default for each
Let's just say i have a Vector of Strings, and I want to output
I have some trouble understanding the output from the following code: int main(void) {
I'm using Stroustrup's swan book. I have run into a problem getting output from
I have solved this problem!!! I found that if i have to use vector<Node*>
As a function argument I get a vector<double>& vec (an output vector, hence non-const)
Given an STL vector, output only the duplicates in sorted order, e.g., INPUT :
Are there any known hash algorithms which input a vector of int's and output
The output we get when printing C++ sources from Eclipse is rather ugly. Is

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.