Search Results

Search found 68 results on 3 pages for 'disp'.

Page 1/3 | 1 2 3  | Next Page >

  • How can I flush the output of disp in Octave?

    - by Nathan Fellman
    I have a program in Octave that has a loop - running a function with various parameters, not something that I can turn into matrices. At the beginning of each iteration I print the current parameters using disp. The first times I ran it I had a brazillion warnings, and then I also got these prints. Now that I cleaned them up, I no longer see them. My guess is that they're stuck in a buffer, and I'll see them when the program ends or the buffer fills. Is there any way to force a flush of the print buffer so that I can see my prints?

    Read the article

  • Matlab postpones disp calls when doing demanding calculations why is that?

    - by Reed Richards
    I am implementing an algorithm in Matlab. Among other things it calculates shortest paths etc. so its quite demanding for my old computer. I've put out disp calls through out the program to see what's happening all the time. However when starting on a particulary heavy for loop the disp seemes not to be called until the loop is over even though it comes before the loop. Why is that? I though that Matlab was really linear or am I just choking it with to many calculations and the disp calls get the lowest priority?

    Read the article

  • How to populate RRD database with CPU and MEM usage data?

    - by Tomaszs
    I have a Lighttpd server (on Centos) and would like to display 4 graphs: lighttpd traffic, lighttpd requests per second, CPU usage and MEM usage. I've set place for rrd database for lighttpd config like this: rrdtool.binary = "/usr/bin/rrdtool" rrdtool.db-name = "/var/www/lighttpd.rrd" And put into my WWW cgi-bin sh file that gets data from lighttpd RRD file and creates graphs of traffic and requests per second like this: #!/bin/sh RRDTOOL=/usr/bin/rrdtool OUTDIR=//var/www/graphs INFILE=/var/www/lighttpd.rrd OUTPRE=lighttpd-traffic WIDTH=400 HEIGHT=100 DISP="-v bytes --title TrafficWebserver \ DEF:binraw=$INFILE:InOctets:AVERAGE \ DEF:binmaxraw=$INFILE:InOctets:MAX \ DEF:binminraw=$INFILE:InOctets:MIN \ DEF:bout=$INFILE:OutOctets:AVERAGE \ DEF:boutmax=$INFILE:OutOctets:MAX \ DEF:boutmin=$INFILE:OutOctets:MIN \ CDEF:bin=binraw,-1,* \ CDEF:binmax=binmaxraw,-1,* \ CDEF:binmin=binminraw,-1,* \ CDEF:binminmax=binmaxraw,binminraw,- \ CDEF:boutminmax=boutmax,boutmin,- \ AREA:binmin#ffffff: \ STACK:binmax#f00000: \ LINE1:binmin#a0a0a0: \ LINE1:binmax#a0a0a0: \ LINE2:bin#efb71d:incoming \ GPRINT:bin:MIN:%.2lf \ GPRINT:bin:AVERAGE:%.2lf \ GPRINT:bin:MAX:%.2lf \ AREA:boutmin#ffffff: \ STACK:boutminmax#00f000: \ LINE1:boutmin#a0a0a0: \ LINE1:boutmax#a0a0a0: \ LINE2:bout#a0a735:outgoing \ GPRINT:bout:MIN:%.2lf \ GPRINT:bout:AVERAGE:%.2lf \ GPRINT:bout:MAX:%.2lf \ " $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP -w $WIDTH -h $HEIGHT OUTPRE=lighttpd-requests DISP="-v req --title RequestsperSecond -u 1 \ DEF:req=$INFILE:Requests:AVERAGE \ DEF:reqmax=$INFILE:Requests:MAX \ DEF:reqmin=$INFILE:Requests:MIN \ CDEF:reqminmax=reqmax,reqmin,- \ AREA:reqmin#ffffff: \ STACK:reqminmax#00f000: \ LINE1:reqmin#a0a0a0: \ LINE1:reqmax#a0a0a0: \ LINE2:req#00a735:requests" $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP -w $WIDTH -h $HEIGHT Basically it's not my script, i get it from somewhere from the internet. Now i would like to do the same for CPU usage and MEM usage. I don't like to use any additional packages! As you can see lighttpd populates lighttpd.rrd file with traffic data and requests per second. Now i would like to the system to populate second rrd file with CPU and MEM usage, so i can add to sh file code to generate graphs for this data. How can I populate RRD file with CPU and MEM usage data? Please, NO THIRD-PARTY tools !

    Read the article

  • In Drupal 6, is there a way to take a custom field from the latest post to a taxonomy term, and disp

    - by user278457
    The title for this question pretty much sums up what I'm asking. I've got a list of taxonomy terms, and I'm using a view to display the latest post to each one. I'd like to also display a custom field set up in CCK just under this. Currently, I'm just using "date updated" of the taxonomy term itself which was easy to set up in views. I'd like to drill a little deeper and get the custom "event date" field I've added to the content type last posted to the taxonomy term I'm "viewing". I've got a feeling I'm going to have to write my own database query for this. If (I can avoid that){ How do I set up such a view? } Else{ What's the best practice for including lower level database queries alongside views? }

    Read the article

  • Simple Program Question (TI-84 calculator)

    - by John
    I wrote a program (on my TI-84 calculator) to satisfy the following exercise: Write a program that will print all solutions of the inequality ax + b < c, where a, b, and c are entered by the user. In this program the domain of x will be a set of consecutive integers, where the smallest and largest members of the set will also be entered by the user. (Hint: Use a FOR . . . NEXT loop to test each integer from smallest to largest.) This is the code I have: :Input "A=",A :Input "B=",B :Input "C=",C :Disp "DOMAIN FOR X" :Input "MIN=",D :Input "MAX=",E :For(X,D,E,1) :If AX+B<C :Disp X :End I sort of figured it out by chance; I don't really know how 'If' works inside 'For.' I wanted to have it tell me if there is no solution, though, so I tried: :Input "A=",A :Input "B=",B :Input "C=",C :Disp "DOMAIN FOR X" :Input "MIN=",D :Input "MAX=",E :For(X,D,E,1) :If AX+B<C :Then :Disp X :Else :Disp "NO SOLUTION" :End But this returns the value for "MIN=" Why is this? Can anyone help me understand these work?

    Read the article

  • Selecting an area from displayed image using CImg library

    - by sravan
    hi all, i use CImg for my image processing work. I had written a small piece of code which is follows: #include "../CImg.h" #include <iostream> using namespace std; using namespace cimg_library; int main(int argc,char**argv) { CImg<int> img(argv[1]); CImgDisplay disp; disp.assign(img); while(!disp.is_closed) disp.wait(); return 0; } Now i want to select an area from the displayed image. Can some one tell me how to select an area from displayed image and store the selected pixels, and display the selected region in different display window. If some one can provide code, it will be of great help to me. Thank you all

    Read the article

  • read angles in radian and convert them in degrees/minutes/seconds

    - by Amadou
    n=0; disp('This program performs an angle conversion'); disp('input data set to a straight line. Enter the name'); disp('of the file containing the input Lambda in radian: '); filename = input(' ','s'); [fid,msg] = fopen(filename,'rt'); if fid < 0 disp(msg); else A=textscan(fid, '%g',1); while ~feof(fid) Lambda = A(1); n = n + 1; A = textscan(fid, '%f',1); end fclose(fid); end Alpha=Lambda*180/pi; fprintf('Angle converted from radian to degree/minutes/seconds:\n'); fprintf('Alpha =%12d\n',Alpha); fprintf('No of angles =%12d\n',n);

    Read the article

  • Hiding <option>s in IE

    - by Mark
    I wrote this nifty function to filter select boxes when their value is changed... $.fn.cascade = function() { var opts = this.children('option'); var rel = this.attr('rel'); $('[name='+rel+']').change(function() { var val = $(this).val(); var disp = opts.filter('[rel='+val+']'); opts.filter(':visible').hide(); disp.show(); if(!disp.filter(':selected').length) { disp.filter(':first').attr('selected','selected'); } }).trigger('change'); return this; } It looks at the rel property, and if the element indicated by rel changes, then it filters the list to only show the options that have that value... for example, it works on HTML that looks like this: <select id="id-pickup_address-country" name="pickup_address-country"> <option selected="selected" value="CA">Canada </option> <option value="US">United States </option> </select> <select id="id-pickup_address-province" rel="pickup_address-country" name="pickup_address-province"> <option rel="CA" value="AB">Alberta </option> <option selected="selected" rel="CA" value="BC">British Columbia </option> <option rel="CA" value="MB">Manitoba </option>... </select> However, I just discovered it doesn't work properly in IE (of course!) which doesn't seem to allow you to hide options. How can I work around this?

    Read the article

  • using load instead of other I/O command

    - by Amadou
    How can I modify this program using load-ascii command to read (x,y)? n=0; sum_x = 0; sum_y = 0; sum_x2 = 0; sum_xy = 0; disp('This program performs a least-squares fit of an'); disp('input data set to a straight line. Enter the name'); disp('of the file containing the input (x,y) pairs: '); filename = input(' ','s'); [fid,msg] = fopen(filename,'rt'); if fid<0 disp(msg); else [in,count]=fscanf(fid, '%g %g',2); while ~feof(fid) x=in(1); y=in(2); n=n+1; sum_x=sum_x+x; sum_y=sum_y+y; sum_x2=sum_x2+x.^2; sum_xy=sum_xy+x*y; [in,count] = fscanf(fid, '%f',[1 2]); end fclose(fid); x_bar = sum_x / n; y_bar = sum_y / n; slope = (sum_xy - sum_x*y_bar) / (sum_x2 - sum_x*x_bar); y_int = y_bar - slope * x_bar; fprintf('Regression coefficients for the least-squares line:\n'); fprintf('Slope (m) =%12.3f\n',slope); fprintf('Intercept (b) =%12.3f\n',y_int); fprintf('No of points =%12d\n',n); end

    Read the article

  • MATLAB is changing variables when I do not want it to.

    - by WVUstudent
    Here is my problem in a small bit of code used as an example, trial(0) function [] = trial(test) disp(test) if(test == 1) disp('test is one') test = 0; end disp(test) Matlab prints out this: 0 'test is one' 0 This is not my real code, there are over 500 lines of it, but this is a section of my code where the problem has risen. I have used the search function to see if I have been incrementing any variables anywhere, and have put in over 2 hours trying to see why MATLAB is changing my variables when I don't want it to.

    Read the article

  • Catching KeyboardInterrupt when working with PyGame

    - by Sebastian P.
    I have written a small Python application where I use PyGame for displaying some simple graphics. I have a somewhat simple PyGame loop going in the base of my application, like so: stopEvent = Event() # Just imagine that this eventually sets the stopEvent # as soon as the program is finished with its task. disp = SortDisplay(algorithm, stopEvent) def update(): """ Update loop; updates the screen every few seconds. """ while True: stopEvent.wait(options.delay) disp.update() if stopEvent.isSet(): break disp.step() t = Thread(target=update) t.start() while not stopEvent.isSet(): for event in pygame.event.get(): if event.type == pygame.QUIT: stopEvent.set() It works all fine and dandy for the normal program termination; if the PyGame window gets closed, the application closes; if the application finishes its task, the application closes. The trouble I'm having is, if I Ctrl-C in the Python console, the application throws a KeyboardInterrupt, but keeps on running. The question would therefore be: What have I done wrong in my update loop, and how do I rectify it so a KeyboardInterrupt causes the application to terminate?

    Read the article

  • Python decorator question

    - by nsharish
    decorator 1: def dec(f): def wrap(obj, *args, **kwargs): f(obj, *args,**kwargs) return wrap decorator 2: class dec: def __init__(self, f): self.f = f def __call__(self, obj, *args, **kwargs): self.f(obj, *args, **kwargs) A sample class, class Test: @dec def disp(self, *args, **kwargs): print(*args,**kwargs) The follwing code works with decorator 1 but not with decorator 2. a = Test() a.disp("Message") I dont understand why decorator 2 is not working here. Can someone help me with this?

    Read the article

  • python class decorator question?

    - by nsharish
    decorator 1: def dec(f): def wrap(obj, *args, **kwargs): f(obj, *args,**kwargs) return wrap decorator 2: class dec: def __init__(self, f): self.f = f def __call__(self, obj, *args, **kwargs): self.f(obj, *args, **kwargs) A sample class, class Test: @dec def disp(self, *args, **kwargs): print(*args,**kwargs) The follwing code works with decorator 1 but not with decorator 2. a = Test() a.disp("Message") I dont understand why decorator 2 is not working here. Can someone help me with this?

    Read the article

  • iPhone SDK NSString To NSDate

    - by disp
    I got a string from parsing a XML file which looks like this: Fri, 09 Apr 2010 00:00:45 +0200 and the corresponding pattern should be this "EEE, dd MMM yyyy HH:mm:ss ZZ", but I get (null). This is my code: NSString *dateString = @"Fri, 09 Apr 2010 00:00:45 +0200"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZ"]; NSDate *date = [dateFormatter dateFromString:dateString]; NSLog(@"date:%@",date); // result date:(null) Edit: This works for me now, I had to switch to en-US locale: NSLocale* usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setLocale:usLocale]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZ"]; NSDate *date = [dateFormatter dateFromString:dateString];

    Read the article

  • TTNavigator three20 openURLAction

    - by disp
    I'm new to three20 and trying to find my way through the TTNavigator class. I try to push to a new view via the URL system. So I used openURL: animated: method which works just fine, but it's deprecated, and I know that I should use openURLAction instead, but this has no animated: parameter. Am I missing something?

    Read the article

  • 2D Engine for iPhone OS

    - by disp
    I have a pretty simple 2D flash game. It's a jump n run sidescroller and I want to port it to the iPhone. But what is the best way to do it? There is Adobe Flash Pro CS5 but I'd rather program it from the scratch in an iPhone environment. Are there any top games done by open source framekworks? Which is the best way to go?

    Read the article

  • iPhone App with Thirdparty Code - Licence Question

    - by disp
    What do I need to include if my iPhone App uses some third party code under an opensource licence for example BSD or MIT, before submitting for AppStore approval? Is it enough if I let original code with it's comments untouched or do I need to include a readme file where I describe that I used "xyz's framekwork under licence abc" or something like that?

    Read the article

  • iPhone: Helpful Classes or extended Subclasses which should have been in the SDK

    - by disp
    This is more a community sharing post than a real question. In my iPhone OS projects I'm always importing a helper class with helpful methods which I can use for about every project. So I thought it might be a good idea, if everyone shares some of their favorite methods, which should have been in everyones toolcase. I'll start with an extension of the NSString class, so I can make strings with dates on the fly providing format and locale. Maybe someone can find some need in this. @implementation NSString (DateHelper) +(NSString *) stringWithDate:(NSDate*)date withFormat:(NSString *)format withLocaleIdent:(NSString*)localeString{ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; //For example @"de-DE", or @"en-US" NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:localeString]; [dateFormatter setLocale:locale]; // For example @"HH:mm" [dateFormatter setDateFormat:format]; NSString *string = [dateFormatter stringFromDate:date]; [dateFormatter release]; [locale release]; return string; } @end I'd love to see some of your tools.

    Read the article

  • Problem in matlab with too many outputs

    - by Ben Fossen
    I am writing a Matlab program for simpson's rule I keep getting an error about to many outputs when the program gets to left_simpson = Simpson(a,c,(e1)/2,level, level_max); What is wrong with settinf left_simpson to Simpson(a,c,(e1)/2,level, level_max);? function Simpson(a,b,e1,level, level_max) level = level + 1; h = b - a; c = (a+b)/2; one_simpson = h*(f(a) + 4*f(c) + f(b))/6; d = (a+c)/2; e = (c+b)/2; two_simpson = h*(f(a) + 4*f(d) + 2*f(c) + 4*f(e))/2; if level >= level_max disp('h') simpson_result = two_simpson; disp('maximum levels reached') disp(simpson_result); if abs(two_simpson - one_simpson) < 15*e1 simpson_result = two_simpson + (two_simpson - one_simpson)/15; else left_simpson = Simpson(a,c,(e1)/2,level, level_max); right_simpson = Simpson(c,b,(e1)/2,level, level_max); simpson_result = left_simpson + right_simpson; end end

    Read the article

  • Behavior of <- NULL on lists versus data.frames for removing data

    - by Ananda Mahto
    Many R users eventually figure out lots of ways to remove elements from their data. One way is to use NULL, particularly when you want to do something like drop a column from a data.frame or drop an element from a list. Eventually, a user comes across a situation where they want to drop several columns from a data.frame at once, and they hit upon <- list(NULL) as the solution (since using <- NULL will result in an error). A data.frame is a special type of list, so it wouldn't be too tough to imagine that the approaches for removing items from a list should be the same as removing columns from a data.frame. However, they produce different results, as can be seen in the example below. ## Make some small data--two data.frames and two lists cars1 <- cars2 <- head(mtcars)[1:4] cars3 <- cars4 <- as.list(cars2) ## Demonstration that the `list(NULL)` approach works cars1[c("mpg", "cyl")] <- list(NULL) cars1 # disp hp # Mazda RX4 160 110 # Mazda RX4 Wag 160 110 # Datsun 710 108 93 # Hornet 4 Drive 258 110 # Hornet Sportabout 360 175 # Valiant 225 105 ## Demonstration that simply using `NULL` does not work cars2[c("mpg", "cyl")] <- NULL # Error in `[<-.data.frame`(`*tmp*`, c("mpg", "cyl"), value = NULL) : # replacement has 0 items, need 12 Switch to applying the same concept to a list, and compare the difference in behavior. ## Does not fully drop the items, but sets them to `NULL` cars3[c("mpg", "cyl")] <- list(NULL) # $mpg # NULL # # $cyl # NULL # # $disp # [1] 160 160 108 258 360 225 # # $hp # [1] 110 110 93 110 175 105 ## *Does* drop the `list` items while this would ## have produced an error with a `data.frame` cars4[c("mpg", "cyl")] <- NULL # $disp # [1] 160 160 108 258 360 225 # # $hp # [1] 110 110 93 110 175 105 The main questions I have are, if a data.frame is a list, why does it behave so differently in this scenario? Is there a foolproof way of knowing when an element will be dropped, when it will produce an error, and when it will simply be given a NULL value? Or do we depend on trial-and-error for this?

    Read the article

  • 7 drived classes with one common base class

    - by user144905
    i have written the following code, //main.cpp #include<iostream> #include<string> #include"human.h" #include"computer.h" #include"referee.h" #include"RandomComputer.h" #include"Avalanche.h" #include"Bureaucrat.h" #include"Toolbox.h" #include"Crescendo.h" #include"PaperDoll.h" #include"FistfullODollors.h" using namespace std; int main() { Avalanche pla1; Avalanche pla2; referee f; pla1.disp(); for (int i=0;i<5;i++) { cout<<pla2.mov[i]; } return 0; } in this program all included classes except referee.h and human.h are drived from computer.h. each drived calls has a char array variable which is initialized when a member of a drived class is declared. the problem is that when i declare tow diffrent drived class memebers lets say Avalache and ToolBox. upon printing the char array for one of them using for loop it prints nothing. However if i declare only one of them in main.cpp the it works properly. and the file for computer.h is as such: #ifndef COMPUTER_H #define COMPUTER_H class computer { public: int nump; char mov[]; void disp(); }; #endif ToolBox.h is like this: #ifndef TOOLBOX_H #define TOOLBOX_H #include"computer.h" class Toolbox: public computer { public: Toolbox(); }; #endif finally Avalanche.h is as following: #ifndef AVALANCHE_H #define AVALANCHE_H #include"computer.h" class Avalanche: public computer { public: Avalanche(); }; #endif

    Read the article

  • IE attachEvent on object tag causes memory corruption

    - by larswa
    I've an ActiveX Control within an embedded IE8 HTML page that has the following event MessageReceived([in] BSTR srcWindowId, [in] BSTR json). On Windows the event is registered with OCX.attachEvent("MessageReceived", onMessageReceivedFunc). Following code fires the event in the HTML page. HRESULT Fire_MessageReceived(BSTR id, BSTR json) { CComVariant varResult; T* pT = static_cast<T*>(this); int nConnectionIndex; CComVariant* pvars = new CComVariant[2]; int nConnections = m_vec.GetSize(); for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) { pT->Lock(); CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); pT->Unlock(); IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); if (pDispatch != NULL) { VariantClear(&varResult); pvars[1] = id; pvars[0] = json; DISPPARAMS disp = { pvars, NULL, 2, 0 }; pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL); } } delete[] pvars; // -> Memory Corruption here! return varResult.scode; } After I enabled gflags.exe with application verifier, the following strange behaviour occur: After Invoke() that is executing the JavaScript callback, the BSTR from pvars[1] is copied to pvars[0] for some unknown reason!? The delete[] of pvars causes a double free of the same string then which ends in a heap corruption. Does anybody has an idea whats going on here? Is this a IE bug or is there a trick within the OCX Implementation that I'm missing? If I use the tag like: <script for="OCX" event="MessageReceived(id, json)" language="JavaScript" type="text/javascript"> window.onMessageReceivedFunc(windowId, json); </script> ... the strange copy operation does not occur. The following code also seem to be ok due to the fact that the caller of Fire_MessageReceived() is responsible for freeing the BSTRs. HRESULT Fire_MessageReceived(BSTR srcWindowId, BSTR json) { CComVariant varResult; T* pT = static_cast<T*>(this); int nConnectionIndex; VARIANT pvars[2]; int nConnections = m_vec.GetSize(); for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) { pT->Lock(); CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); pT->Unlock(); IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); if (pDispatch != NULL) { VariantClear(&varResult); pvars[1].vt = VT_BSTR; pvars[1].bstrVal = srcWindowId; pvars[0].vt = VT_BSTR; pvars[0].bstrVal = json; DISPPARAMS disp = { pvars, NULL, 2, 0 }; pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL); } } delete[] pvars; return varResult.scode; } Thanks!

    Read the article

1 2 3  | Next Page >