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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:28:22+00:00 2026-06-15T22:28:22+00:00

I have Matlab R2012a installed on my own computer and Matlab R2009a (multi thread)

  • 0

I have Matlab R2012a installed on my own computer and Matlab R2009a (multi thread) installed on my friend’s computer. Because of the reason that my computer has only 2gb ram whereas my friend’s has 128gb and a better processor, I decided to execute my code on my friend’s computer.

I connected to his computer with a remote desktop connection program, downloaded my code and dataset from dropbox and executed my code. However, my code’s execution did not finish even though an hour passed. (It took about 20 minutes on my computer and if you think that my friend’s system is much more better than mine, it should have taken less than 20 minutes.) Then I waited a few hours more but execution did not finish.

Then, to understand where the problem is, I evaluated the code step by step by hand and noticed that it could not finish the execution of the following loop:

l=1;
for n=1:max_t
    for m=1:t(1,n).numberofPoints
        x_t(l)=t(1,n).matrix(m,1);
        y_t(l)=t(1,n).matrix(m,2);
        z_t(l)=t(1,n).matrix(m,3);
        l=l+1;
    end
end
minx = min(x_t(:));
miny = min(y_t(:));
minz = min(z_t(:));

It is just a simple loop to obtain my minimum point in x,y,z coordinates. (I am sure there is nothing wrong with this loop. It works successfully on my PC.) I know I do not need loops to obtain maximum and minimum points of a struct but I am new to MATLAB and do not know much. Therefore it seemed like the easiest option to me.

I really have to be able to use my friends’ computer because my ram will not be enough for the further process. Therefore I need to solve this problem.

What can be the reason that same code works on my computer but not on my friends’ computer?

  • 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-15T22:28:24+00:00Added an answer on June 15, 2026 at 10:28 pm

    Matlab R2011a introduced dramatic performance improvements when growing arrays in a loop, and I believe R2012a improved those even further.

    Thus, in R2009, the loop simply takes a lot longer to run, since you’re not pre-allocating x_t.

    There are other ways to improve your code as well, here I’ll simply fix the preallocation:

    l=1;
    
    %# preallocate with NaN, so that the values don't interfere with
    %# taking the minimum later
    lMax = sum([t(1,1:max_t).numberofPoints)]);
    [x_t,y_t,z_t] = deal(NaN(lMax,1));
    
    for n=1:max_t
        for m=1:t(1,n).numberofPoints
            x_t(l)=t(1,n).matrix(m,1);
            y_t(l)=t(1,n).matrix(m,2);
            z_t(l)=t(1,n).matrix(m,3);
            l=l+1;
        end
    end
    minx = min(x_t(:));
    miny = min(y_t(:));
    minz = min(z_t(:));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed Matlab r2010a on my computer I need use the function xlsread
I have a matlab structure array Modles1 of size (1x180) that has fields a
I have multiple Matlab versions installed on my PC. To say, R2006b, R2009b, R2010a.
I have a code that works in Matlab version R2010a but shows errors in
I have a Matlab function that creates a cell array with matrixes inside. It
I have a Matlab program that generates a list x = 6.1692 8.1863 5.8092
I have a Matlab program that is running longer than I'd like it to.
I have a matlab script, lets call it master.m, that loads a file called
I have a matlab function img_process that requires the following parameters : image_name intensity
I have a MATLAB matrix, that is 1000x4, to use as an input for

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.