indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Tools > Software > Matlab

Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 17-01-2011, 11:18 AM
Oxymoron's Avatar
Oxymoron Oxymoron is offline
Super Moderator
 
Join Date: Mar 2009
Location: Chennai
Posts: 1,275
Thanks: 4,471
Thanked 4,825 Times in 1,156 Posts
Oxymoron has a reputation beyond repute
Oxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond repute
Default Out of Control Loop - Limiting Computation Time

Using a combination of the while loop and toc command, it is possible to restrict the time (in seconds) for which a loop is run. Below is an example code:

Code:
tic
a = 0;
i = 0;
StopTime = 10; %Seconds
d = [];

while a < StopTime
    b = rand(i); %Random number matrix of the size i*i
    a = toc;
    d(i+1,1) = a; %Time at the end of each run
    i = i + 1;
    continue
end

clear a i StopTime
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 5 Users Say Thank You to Oxymoron For This Useful Post:
  #2 (permalink)  
Old 17-01-2011, 02:55 PM
kkseal kkseal is offline
Hip-py
 
Join Date: Apr 2009
Posts: 4,861
Thanks: 6,464
Thanked 9,316 Times in 4,008 Posts
kkseal has a reputation beyond reputekkseal has a reputation beyond repute
kkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond repute
Default

What does toc command do? (Looks like it cumulates the computation/execution time between each assignment to var a)
__________________
'Growth & Value are joined at the hip' - Warren buffet

Last edited by kkseal; 17-01-2011 at 03:20 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to kkseal For This Useful Post:
  #3 (permalink)  
Old 17-01-2011, 03:14 PM
MurAtt's Avatar
MurAtt MurAtt is offline
indicator
 
Join Date: May 2009
Location: Kolkata
Posts: 9,765
Thanks: 35,227
Thanked 25,141 Times in 8,801 Posts
MurAtt has disabled reputation
Default

fat finger ... either tic at top should be toc or other way round ...
__________________
Trade the Moves, not the Target
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to MurAtt For This Useful Post:
  #4 (permalink)  
Old 17-01-2011, 03:23 PM
kkseal kkseal is offline
Hip-py
 
Join Date: Apr 2009
Posts: 4,861
Thanks: 6,464
Thanked 9,316 Times in 4,008 Posts
kkseal has a reputation beyond reputekkseal has a reputation beyond repute
kkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond reputekkseal has a reputation beyond repute
Default

tic could also be some kind of pre-processing command/directive (does not have the ; that goes with the usual syntax)
__________________
'Growth & Value are joined at the hip' - Warren buffet
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 17-01-2011, 03:39 PM
Oxymoron's Avatar
Oxymoron Oxymoron is offline
Super Moderator
 
Join Date: Mar 2009
Location: Chennai
Posts: 1,275
Thanks: 4,471
Thanked 4,825 Times in 1,156 Posts
Oxymoron has a reputation beyond repute
Oxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond reputeOxymoron has a reputation beyond repute
Default

Originally Posted by kkseal View Post
What does toc command do? (Looks like it cumulates the computation/execution time between each assignment to var a)

Right. Once tic is initiated, toc plots the time taken from the start of tic to the current state.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to Oxymoron For This Useful Post:
Reply

indiTraders - Forum for the Active Indian Trader > Tools > Software > Matlab


Thread Tools
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 Off
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 03:46 AM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2