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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:08:56+00:00 2026-06-13T21:08:56+00:00

I am really a beginner level at matlab. Now I want to have a

  • 0

I am really a beginner level at matlab. Now I want to have a loop, such that it iterates over a vector (not consecutive numbers) which contains a decreasing number of elements through iteration.

For example, I have [1; 2 ;3; 4] (thinking of it as person 1, 2, 3, 4)
then I want to do something such that for example person 1 and 4 gets food, person 2 and 3 left with no food.

In the next round, I want person 2 and 3 (those unassigned)to go through the assignment process again but not 1 and 4.
So I create a vector [2;3] to keep track of those left without food.

However,the for i=1:length(vector) gives me a series of consecutive numbers, what I want is

for i in vector do something; end

How to implement this?

when I just put

i=vector,

Matlab says Index exceeds matrix dimensions

  • 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-13T21:08:58+00:00Added an answer on June 13, 2026 at 9:08 pm

    If you want to loop through an arbitrary vector, just use that vector directly in a for loop. For example:

    vector = [3, 4, 7, 1, 1]
    
    for i = vector
        disp(i)
    end
    

    will output 3 4 7 1 1. This is the equivalent of “for i in vector do something.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a beginner level Json question with MVC.net (I've never really used jquery
I apologize if this is a really beginner question, but I have not worked
I am a Java beginner and, I am not really sure what JMSExceptions are
Really simple but just not getting it. I want to reference a view by
Really beginner question here. I have an NSArray of images which in its last
I am a beginner and got an issue, really head around now. Here is
I'm really a beginner when it comes to regular expressions, and I'm not really
I'm really a beginner to Node.js and I have some questions. Firstly, if I
I have worked on Mozilla Add-on Development in the past (beginner level). But on
(VB Express Level: Beginner) I want to do following, A column from Workbook 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.