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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:01:17+00:00 2026-06-10T14:01:17+00:00

I am new matlab user. Now, I’am doing my work by using matlab software.

  • 0

I am new matlab user.
Now, I’am doing my work by using matlab software. but I have problem to improve my code in order to have fast time execution.
right now, I have to make a matrix(A,10,C)) which has the value integer [ 1 10].
currently, I am using logic randperm. here my code :

for c=1:C,
   for a=1:A,
       result(a,:,c)=randperm(10);
   end
end

but when I tried to analyze with profile viewer. That code take a more time.

so I wish that there is someone want to share his/her experience about this.
thanks you.
regard

  • 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-10T14:01:19+00:00Added an answer on June 10, 2026 at 2:01 pm

    Here’s an alternate solution but it does not have the nice properties of randperm regarding the distribution of your random numbers:

    [~,result_alt] = sort( rand(A,10,C) , 2);
    

    A quick profile shows that your method takes approximately 1.6e-3 seconds on average when A = C = 10 whereas this method takes 5.6e-5 seconds on average.

    Note:

    Older version of MATLAB won’t support the ~ operator. If so, try:

    [vals result_alt] = sort( rand(A,10,C) , 2);
    

    and ignore vals.

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

Sidebar

Related Questions

I'm very new to matlab and am more of an ArcGIS user but I'd
I know that this is probably a simple problem but I am new to
I'm new to matlab classes and have just gone through a couple tutorials and
I have done an layout in my GUI but it did not work ,
I am new to matlab, I have a column vector with binary values I
I am very new to matlab and trying to solve portfolio optimization problem (minimizing
I'm new at Matlab. You may find this question silly but I really wonder
I`m absolutely new in Matlab, so I think it is a dumb question, but
I am quiet new to matlab NN toolbox and have created the following NN
I'm pretty new to MATLAB and I have a simple question. What if I

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.