|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi all.
I ve been using Matlab for quite some time now and recently I ve decided to link a script in C that can be called from the Matlab environment.The code works fine, ouputs the right results but there is a thing about the memory management :it just takes too long!Inside the C code there are 3 nested for loops that under normal coditions (i.e. in a pure C framework ) there would be no latency at all ( at least i think so..). I ve done some searching on memory control in C ( i use mxCalloc() to dynamically allocate memory space) but the delay persists.I think that Matlab always includes some delay when there are calls to external functions,i.e no Matlab's built in ones. If anyone has successfuly managed to call a C script via Matlab plz reply coz my debugging has reached its limits..no apparent reason for this undesirable slowing down. Thx |
| Sponsored Links |
|
|
|
|||||
|
Depending on the loops, this can take a LONG time. To get a rough idea of how many processes you are performing, multiply the three ranges together. Then multiply by the number of lines of code within the loop to get an idea of the effective size of your program. "just 3 nested for loops" can be a tremendous amount of processing time.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||
|
thx anyways panther but lemme put it that way:
suppose a have a variable (double) and a certain array of doubles. I can get rid of the innermost loop if i can write some lines that compare the double variable with each of the array elements and return the index of that element whose subtract from the variable is the minimum for the whole array.That is,I want to know which matrix value is closest to this specific original double value i have as an input here. That would spare me this last loop and relieve the whole code of the main computational burden (now,the main math calculation on doubles take place just there).I dont know how i could do that without a loop. In Matlab, coding is just 2 lines of code but in C? Any help appreciated |
|
|||||
|
It's a similar number of lines in C. I'm not familiar with Matlab, however, so I don't know how much help I'll be.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| JavaScript:Tutorial, Using an External Script | TcM | Javascript | 7 | 09-11-2007 08:39 AM |
| (Script) Copy content to clipboard, how? | annannienann | Visual Basic Programming | 0 | 06-19-2007 06:20 PM |
| Need help with proxy script please | TcM | PHP Forum | 4 | 05-16-2007 10:54 AM |
| Need Help With a Script | tfusion | PHP Forum | 5 | 04-14-2007 08:35 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |