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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:52:49+00:00 2026-06-17T15:52:49+00:00

I have this piece of code which I want to run in parallel. One

  • 0

I have this piece of code which I want to run in parallel. One of the arguments passed to the function containing the parfor loop is a function handle which then is executed inside the parfor loop. Like this

[X] = randstep( X,params,roomfun )
  ...
  parfor i=1:N
    while ~ok
      X(:,i) = A*X(:,i);
      if roomfun(X(:,i))
        ok = 1;
      end
    end
  end

However, MATLAB complains about roomfun, saying it is indexed but not sliced. This is of course not the case since it is function which can be executed fine without the other loop iterations.

Is there any way I can tell matlab this is a function or maybe another way I can organize the loops in order to get this running in parallel?

  • 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-17T15:52:49+00:00Added an answer on June 17, 2026 at 3:52 pm

    First of all, this is only a warning, not an error. So the parfor loop should run just fine.

    Secondly, the warning about something being indexed but not sliced comes from mlint, which, while pretty good, doesn’t understand everything, so if it interprets something wrong, don’t sweat it.

    Thirdly, in R2012b, I don’t even get the warning anymore (mlint has gotten smarter), which further shows that there’s nothing to worry about.

    Finally, if there really was a slicing problem, it’s still not an issue that would prevent the loop from running in parallel – all the warning says is that an array is sent in its entirety to the workers, which can slow down the parfor loop in case the array is large.

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

Sidebar

Related Questions

Possible Duplicate: php loop through associative arrays i have this piece of code which
I have this piece of code in a function. I want to print the
I have this piece of code which check the last customer_id from the db.
I have this piece of code which I'm hoping will be able to tell
I am somewhat new to R, and i have this piece of code which
Ok i have this piece of code from which i took from W3schools :-
I have this piece of Open MP code here which performs an integeration of
I have this piece of code: if(($op == q)); then which throws out this
I have a relatively small piece of initializer code that I want to run
I have this piece of code which i am using on another area 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.