Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-2007, 10:51 AM
rattlepanos rattlepanos is offline
Newbie
 
Join Date: Feb 2007
Posts: 4
Rep Power: 0
rattlepanos is on a distinguished road
Default calling C script from via Matlab

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 02-15-2007, 12:10 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,418
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-15-2007, 04:53 PM
rattlepanos rattlepanos is offline
Newbie
 
Join Date: Feb 2007
Posts: 4
Rep Power: 0
rattlepanos is on a distinguished road
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-16-2007, 12:06 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,418
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

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


All times are GMT -5. The time now is 02:09 AM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads