Averages for number of loops

Hi all

I have a code (attached) in which a triangular wave is supposed to a magnetic field of ramp up and down to very low frequency (0.1 Hz or low). Reading (X) vs keithley reading field (Y) represented by two random numbers generators must be taken in synchronization with the triangular wave point by point. I would be very grateful if you could help to achieve the following objectives:

1. by taking the average for a few cycles. Basically, I would define the number of loops in the outer circle to the loop and the number of sampling inside everything in a loop and then take the average between the loops.

(Data for data of loop2 +... + loop1) + data to loop n/n

2. the averages should be written to the text file and at the same time, I hope I always get the full date in the file action.

Thank you

Hadi

Assuming that you want to monitor the data happens, I would like to initialize several arrays, both to keep the x and are data and to keep the number of each 'package '.

Now, simply add the new data to the existing elements while incrementing the corresponding number. Dividing by the count will give you the way to be represented graphically. Here's a simple rewrite. The "collection must match the size of the field ramp, so it shouldn't be a separate control, I think. Currently, you graph the two random channels. You would you rather them the two graphic vs of the field instead? You want front and back scans averaged individually or must they go to the same average with a half data table?

You save operation still seems a little convoluted. How do you actually data to be organized in the final file?

Here is a quick project to help you get started.

Tags: NI Software

Similar Questions

  • Procedure 'IN' settings and in NUMBER of loop dbms_output

    I have this procedure which takes two values, a name and a number, as parameters. I do things with them, then try of the output result.

    The code will run well and produce the correct result without printing through DBMS with the loop FOR (I RUN the procedure and manually doing a SELECT on the view and the values are correct). Then I deleted a word in the code, spruced up the same word in the same place in the code, and suddenly I had a different and incorrect result. After you delete and retype everything code for fear of a ghost or something character, it ran fine again without the DBMS FOR part print loop. I typed in the loop FOR and now it does not yet work with errors on the assignment of variable "temp" and "temp1". It worked fine before the additional code has been added. It makes no sense to me.

    I use Oracle SQL Developer.

    The code runs and the results I want, but I keep running in what appears to have problems with the development software. IIF someone could look at the code and help I would really appreciate it. I spent many, many hours on this...

    CODE:

    PROCEDURE GetThem (nameIn IN varchar2, percIn IN number) AS

    Temp varchar2 (30): = '& nameIn'; -SOMETIMES GETTING ERRORS OF TYPE HERE INCORRECT ATTRIBUTION, SOMETIMES NOT...
    number of Temp1: = '& percIn'; -HERE TOO, SAME AS ABOVE

    BEGIN


    EXECUTE IMMEDIATE ' VIEW to CREATE or REPLACE personTotal AS
    SELECT person, COUNT (name) AS total FROM (SELECT DISTINCT name, comments FROM person person WHERE! = temp) GROUP BY person ';

    EXECUTE IMMEDIATE ' VIEW to CREATE or REPLACE sharedTotal AS
    SELECT p.person, COUNT (DISTINCT name) AS best of observations p WHERE p.person! = temp AND p.name IN (SELECT DISTINCT observations g WHERE g.person = temp g.name) GROUP BY p.person';

    FOR tt IN (SELECT p.person FROM personTotal p, sharedTotal s p.person WHERE = temp1 AND s.person < = s.bhave/p.total ORDER BY person)

    LOOP

    dbms_output.put_line (' ' | tt.person |) ' ' ); -SHOULD GENERATE SOME RESULTS HERE BUT UNTESTED

    END LOOP;

    END GetThem;

    Hi, Ben.

    Aymen says:
    Frank,

    Thank you once again. I have looked at the code and I'm testing it in a procedure.

    I do not ask more of you, but I'm going to...

    I'm a student in computer engineering and a data base of the course.

    Then do not use the query I posted earlier. Your teacher will give you more credit to submit your own work, instead of copying someone else, no matter how elegant which can be. An approach as you suggested above will be fine for this mission.

    It is an assignment that I worked on 4 days with what is the last problem. I was not aware of the existence of procedures util, I've seen this problem in my mission.

    I have been searching on the internet and got lots of information on procedures, but they are general examples and I don't understand how they apply to my case.

    There was therefore no preparatory work on the procedures in your class? I find it quite cruel.

    I still have a problem with the part of the output and also, I get an error when I place the SELECT statement in the procedure. (Error (8.7): PLS-00428: an INTO clause in this SELECT statement) It seems that he wants me to put the result in a variable.

    When you run a query in SQL * more (or most any front-end) you're doing 2 things:
    (1) obtain data tables in the database in a result set, and
    (2) display that game results
    SQL * more autiomatically makes two things together, so you often do not even consider them as separate steps. In PL/SQL, explicitly do you somehting for each step separately.

    Here's what I found:

    -Use an output variable, declare it before calling the procedure and put it in the settings and then assign it the value to be returned in the variable.

    That's right, but it's the only way to make a query in PL/SQL.
    Another way, better for this assignment, is to use a cursor loop, as you did in your first post.

    Consider this problem: write a procedure which, for a specific job in the table scott.emp, considers people who have this work and who has wages are at least as high as the average salary for this job in their own departments (counting their own salaries).
    Here is information on all the people with job = 'CLERK ":

    `   DEPTNO ENAME             SAL JOB
    ---------- ---------- ---------- ---------
            10 MILLER           1300 CLERK
            20 SMITH             800 CLERK
            20 ADAMS            1100 CLERK
            30 JAMES             950 CLERK
    

    In the 10 departments, there as a CLERK, namely MILLER. The sal average clerks in 10 1300 dept, sal MILLER is equal to that, if MILLER should be included in the output.
    Dept = 30 is another trivial case, like dept = 10.
    Dept = 20 is more interesting. The average sal for clerks in dept 20 is (800 + 1100) / 2 = 950. Sal of SMITH is less than 950, SMITH should not be in the output. Sal of ADAMS is above 950, ADAMS should be in the output.

    Here's a way to write a procedure that gets these results:

    CREATE OR REPLACE PROCEDURE     avg_or_above
    (       in_job       VARCHAR2
    )
    AS
    BEGIN
         FOR  this_emp  IN (
                                     WITH     avg_by_dept     AS
                         (
                                 SELECT    deptno
                              ,             AVG (sal)     AS avg_sal
                              FROM      scott.emp
                              WHERE     job     = in_job
                              GROUP BY     deptno
                         )
                         SELECT  e.ename
                         ,           e.sal
                         FROM    scott.emp        e
                         JOIN    avg_by_dept  a  ON  e.deptno  = a.deptno
                         WHERE   e.sal     >= a.avg_sal
                         AND     e.job     = in_job
                     )
         LOOP
              dbms_output.put_line (  RPAD (this_emp.ename, 12)
                             || TO_CHAR (this_emp.sal, '99999')
                             );
         END LOOP;
    END     avg_or_above;
    /
    SHOW ERROR
    

    In SQL * Plus, you can call the procedure as follows:

    SET     SERVEROUTPUT     ON
    
    EXEC  avg_or_above ('CLERK');
    

    and the output will look like this:

    ADAMS         1100
    JAMES          950
    MILLER        1300
    

    Here's how it works:

    FOR  x IN (q)
    LOOP
        ...     -- Code here is "inside" the loop
    END LOOP;
    

    runs a query q. Like any question, q can begin with the SELECT keyword or keyword WITH.
    For each row returned by the query q, the results of this line are placed in the variable x, which is a data structure created automatically to have an element for each column in the query. In this example, the query produces two columns (an ename called, which is a VARCHAR2, and the other called sal, which is a NUMBER), then x has two components: the x.ename (which is a VARCHAR2) and x.sal (which is a NUMBER). Inside the loop (i.e. after the LOOP but before the END LOOP statement) you can use x.ename any place where you can use a VARCHAR2 expression, and you can use x.sal everywhere where you can use a NUMBER. In this case, the body of the loop includes only one declaration, a call to dbms_output.put_line. However, you can have several statements between the instructions of LOOP and END_LOOP if you need to.

    It's everything you need to run a query and display its results in PL/SQL. There are other ways, but I think this one will do well enough for this mission.

    Note that there is no need of all views. The avg_by_dept of the subquery is like a point of view. In fact, by looking at only the main request in the cursor above:

    ...                     SELECT  e.ename
                         ,           e.sal
                         FROM    scott.emp        e
                         JOIN    avg_by_dept  a  ON  e.deptno  = a.deptno
                         WHERE   e.sal     >= a.avg_sal
                         AND     e.job     = in_job
    

    He has nothihng to indicate if the avg_by_dept is a table, a view, or a subquery, and it does not affect the query of some sort.

  • Time for a while loop to run once

    Hello guys,.

    I want to measure the time for a while loop to run once. There is a piece of code raised. So I just created a simple VI to try, please let me know which is the right way to do it?

    And I wondered, when I run the VI without highlighting the execution, he wouldn't give me a number, maybe it's because the code is simple and really fast? I have to highlight all the time?

    Thank you

    Not quite right.  Both get primitive value time will run at the same time.  use an image sequence to force the order of execution, as shown.  I also brought in the relitve of accuracy seconds vi of VI. LIB\utilities because it depends on the clock of the system rather than the mSec timer accuracy.

  • loop for and while loop with empty table entry

    Hello

    I have a question with loop and loop.

    When a constant empty array (zero element) is connected to the loop For with "allowing the index", there are no interactions performed in loop For. But, if the loop is replaced by any loop, no problem.

    LabVIEW 2010

    Hello

    It is ok. I have no problem at all.

    For the 'loop' For when you connect the table thanks to indexing, the number of iterations is set to the size of the array. The iteration number assigned to N (in your case 10) is ignored.

    For the 'While' loop the number of iteration is defined by the Boolean Condition and the size of the array is ignored.

    Paul

  • "Setup is preparing your computer for first use" loop problem

    Hello, I was hoping you guys could help out me with a big problem, I ran across when trying to install Windows 7 on a desktop computer new, custom - build. I managed to successfully install my Windows 7 64-bit, it appeared, but when I try to run it, that I will meet a black screen that says "Setup is preparing your computer for first use" and it will stay there forever, I would say. I let it run all night and didn't go anywhere.

    I tried to start in safe mode, and Windows was loading files sys32, he got to "Classpnp.sys" and it froze. After a few minutes, the screen is blacked out, and I got fired the familiar screen "Setup is preparing your computer for first use.

    I bought the copy of Windows 7 nine FRY, there will be no problem with that. My HD is a (new) 240 GB PNY Optima SSD, my mobo is a (new) Z97X-SLI Gigabyte, and I have 16 GB of RAM. All these things have been recognized by my BIOS, it seems that everything is properly connected.

    I tried to install Windows 7 on a second time and exactly the same thing happened. I also tried to repair the installation to start upward, but he finds no problems. Also a check of the memory and the disk has verified without any problem. The only things I plugged are my monitor, keyboard, and mouse.

    Does anyone know of a workaround for this screen loop "first use"? Any help would be greatly appreciated.

    Set of utilities to test for computer HARDWARE manufacturers:

    Note: If you are Overclocking or use an automatic overclocking or BIOS power saving features, start by disabling: Intel EIST, Turbo Mode, Cool and pretty and fall back to the speed of stock as a starting point.

    Disconnect any other (additional) internal hard drives and external USB devices.

    Look for any loose hard drive power or cables SATA, graphics card or other power cables.

    First run Memtest86 +:

    It runs from a floppy disk or CD and should eliminate or confirm if one or more of your memory

    sticks are bad or the values of the SPD in the BIOS are correct.

    Let it run for as long as you can: 2,4,6,8 or several hours (at least 3 full passes), if no errors at that time then your ram is OK.

    http://www.memtest.org/

    Memtest86 + Guide/How To (use the.) ISO to create a bootable CD)

    http://www.overclockers.com/forums/showthread.php?t=409152

    Test your hard drive

    Intel® drive SSD Toolbox

    https://Downloadcenter.Intel.com/Detail_Desc.aspx?AGR=Y&DwnldID=18455

    Corsair SSD Toolbox:

    http://www.Corsair.com/en-us/blog/2013/may/the-Corsair-SSD-Toolbox

    Toolbox of Kingston:

    http://www.Kingston.com/us/support/technical/sandforce_ssd_toolbox.aspx

    OCZ Toolbox: http://ocz.com/consumer/download/firmware

    Support PNY: http://www.PNY.com/support/contact-us

    Samsung: http://www.samsung.com/global/business/semiconductor/minisite/SSD/global/html/about/whitepaper07.html

    Samsung Magican review:

    http://www.TweakTown.com/articles/5638/Samsung-magician-4-2-first-look-new-SSD-Toolkit-adds-rapid-mode/index.html

    SanDisk SSD Toolkit: http://kb.sandisk.com/app/answers/detail/a_id/9328/

    Seagate: http://www.seagate.com/support/internal-hard-drives/laptop-hard-drives/laptop-600-ssd/

    Life of the SSD: http://ssd-life.com/

    = Is installed after Windows =.

    Device drivers: have you installed latest drivers from device of the manufacture of the motherboard?

    Check their support site for the latest drivers as the CD that came with the computer

    or motherboard may be older and less stable drivers.

    Visit the download of the manufacture of the graphics card:

    Download and install the most recent Windows 7 or 8 drivers for your card.

    ATI: http://support.amd.com/us/gpudownload/Pages/index.aspx

    NVIDIA: http://www.nvidia.com/Download/index.aspx?lang=en-us

    See also the test of 'Smoke box' Nvidia or other demos: http://www.nvidia.com/object/cool_stuff.html#/demos

    or equivalent ATI.

    Prime 95:

    http://www.Mersenne.org/freesoft/

    It's a stand alone .exe file contained in an archive .zip.

    Simply choose to run the 'stress test' option for 8 hours or more.

    If your PC can pass this test, your memory and CPU

    are very good (close the housing cover in order to maintain adequate ventilation)

    Core Temp:

    The temperature of each core of the processor.

    Note: For the overclockers using stock radiator and cooling fan Intel/AMD you can expect

    a range of 35 to 40 at idle and 60 to 65 C max temperature when running Prime95.

    http://www.alcpu.com/CoreTemp/

    CPU ID (CPUZ): http://www.cpuid.com/cpuz.php

    Watch the clock speed of the CPU under various conditions of loading

    (when using speed step technology Intel EIST).

    #1 Note:

    CPU - ID has two tabs - tab 'Memory' that shows the actual speed of the memory

    and the "SPD" tab shows the nominal speeds for each memory location that is filled.

    #2 Note:

    Compare the two values, the actual speed of the memory must not exceed the rated speed of your memory.

    CPUID HWMonitor: Hardware program that reads the sensors of health main PC monitoring systems.

    voltages, temperatures, fans speed.

    http://www.CPUID.com/HWMonitor.php

    Speccy:

    Advanced for your PC system information tool.

    Need to know what's inside your computer?

    No problem! Speccy will give you all the information you need.

    Note: May or may not show the motherboard manufacturing.

    Overview: https://www.piriform.com/speccy

    Free version: https://www.piriform.com/speccy/download

    Test of Stress of FurMark GPU (graphics card):

    http://www.oZone3D.NET/benchmarks/fur/

    Pass marks burn in test: http://www.passmark.com/

    Burnin test, and their test bench at the same time give a good workout from all the major parts of Windows.

    HD Tune:

    Provides information of the car and has an option (tab scan error) to test your drive.

    http://www.hdtune.com/

    CrystalDiskInfo:

    http://CrystalMark.info/software/index-e.html

    User Manual: http://crystalmark.info/software/CrystalDiskInfo/manual-en/

    Monitors the State of health and the temperature. Solid State Drives brackets (value of the software).

    SpeedFan:

    Monitors internal temperatures and has a function of analysis health online (SMART tab) for hard disks drive.

    It displays your drives model number and compares your drive with other discs of the same brand and model.

    Note: Unfortunately now includes a lot of bloatware, be very careful when installing remove bloatware.

    http://www.almico.com/SpeedFan.php

    GPU - Z:

    A utility light, designed for you give information about your video card and GPU.

    http://www.techpowerup.com/GPUZ/

    PC WIZARD:

    A powerful utility designed especially for detection of hardware, also analyses more.

    He is able to identify a large scale of system components and supports the latest technologies

    and standards.

    http://www.CPUID.com/pcwizard.php

    J W Stuart: http://www.pagestart.com

  • WAIT % - % IDLE, what is the average for a virtual machine?

    I did some research on performance of VM problems and worked with the media to see that there is maybe a bottle neck IO that occur with a virtual VMware machine I have performance problems on. The technician found that the WAITING % - % IDLE on average for this virtual machine is around 200%. The tech said it was abnormally high. I forgot to ask her what was normal but wanted to put a post to see if some people out there know what they are on average. What is an average number of see? I have the system done nothing right now and I see 579% waiting and 372% IDLE. The technology has been able to confirm that no IO queue was occurring in the VMkernel or on the HBA controller.

    Some average % positions would be useful. Thank you.

    gdewulf18480 wrote:

    Supposibly the amount of time in a State of waiting for I/O is the WAIT - IDLE % difference. I was wondering if anyone had the numbers for this feeling. Is there anyone with some of them?

    Q: How will I know the VCPU world waiting for I/O events?

    A: WAIT - % IDLE % can give you an estimate on how much time processor is spent waiting for I/O events. It is an estimate only, because the world wait perhaps for other than the i/o resources. Note that we should do it only for the worlds of the WWW, not the other kind of worlds. Because the VMM worlds represent the best guest behavior. For the disk i/o, another alternative is to read the disk latency stats that we explain in the drive section.

    WAIT % by itself cannot be used, you must develop and examine the individual vCPU % EXPECTATION values and subtract their idle time.  You can't do it on the initial view of a single line by VM CPU in esxtop.  If technology that you mentioned did not explain it, he doesn't know what it takes.

    I have lots of virtual machines that are never less than 300% when I wait - % idle and I have no problems.

    It is an example, I caught NimSoft server:

    DHSNMS1 100 100 5 192.63 193,80 0.24 0.03 291,44 1.04

    %EST USED (s) 192 - in other words, almost two processors are used 100%

    The %Idle is 1.04% WAIT 291.44 - according to the calculation of waiting idle, I have a super serious problems of e/s past  But this isn't the case, and expanding, I can see that.

    5665 vmware-vmx 100 1 0.09 0.11 100.00 0.00 0.00 0.01

    5667 100 vmassistant.566 1 0.62 0.65 99,63 0.00 0.00 0.00

    5703 100 mks:DHSNMS1 1 0.01 0.01-100.00 0.00 0.00 0.00

    5704 vcpu 100 - 0:DHSNMS1 1 32,35 32.88 67,28 0.28 0.11 67,14

    5705 vcpu 100 - 1:DHSNMS1 1 31,58 32.05 68.11 0.00 67.85 0.12

    So the changed values unfortunately because of ESXTOP bike when you develop... which is annoying, but anyway.  In this you see % waiting is 67 and 68 with another respectively being 3 to 100% (which is normal) and the idle being %, 0, 0, 0, 67 and 67.8.  Doing the calculation on the processors shows a wait - slowed virtually 0 - or very little IO wait past with processors.  But if you add up all the expectations of % and % is idling, you have 434ish, and the 134ish and do the calculation is the difference of 300 - which is the 3 who are always 100%.

    So there is no way we can answer your question, we can only help you to understand how the values should be interpreted.

    Waiting for i/o States almost always go on the disc anyway, it is unlikely, therefore, the network or the user entered, looking at the stats of disc ESXTOP is a much better way to determine if there is a problem of e/s.

  • While why broken arrow will not appear for a timed loop

    Hi all

    I need a little clarification relative to normal while loop and timed looping in labview.

    In labview, if I keep a while loop on a block diagram, broken arrow will appear in the upper left corner of the window indicating the error. It displays error because I have not wired conditional terminal of the while loop.

    But same is not the case for a timed loop. Can someone tell me what is the reason behind this...

    If I release the conditional terminal of the timed while loop, it runs in infinfite time like a normal while loop. Then y labview behaves differently for these two types of loops in the scenario above.

    FYI... I'm using labview 2009.

    Waiting for response.

    Thank you

    Herald

    Ruben,

    the reason is quite simple: call loops are mostly real-time and FPGA targets. Since most of the applications on these targets work continuously (at least this is more often the task), it is possible to create a loop that does not end. So the timed loop by default assumes that there is no need of a stop button.

    The 'normal' while loop needs code for termination (conditional terminal) because normal applications on Windows/Linux/Mac are used to be fair...

    hope this helps,

    Norbert

  • decimal and the thousand separator for number and currency formats

    Decimal and thousands separators for number and currency formats are not the same, please change your windows settings

    Tab Control Panel / regional and Language Options/Format is used to adjust these. Good luck, Rick Rogers, aka "Crazy" - Microsoft MVP http://mvp.support.microsoft.com Windows help - www.rickrogers.org

  • How to calculate daily, hourly average for the very large data set?

    Some_Timestamp

    "Parameter1" Parameter2
    1 JANUARY 2015 02:00. 00:000000 AM - 07:002341.4534676341.4534
    1 JANUARY 2015 02:00. 01:000000 AM - 07:002341.4533676341.3
    1 JANUARY 2015 03:04. 01:000000 PM - 07:005332.3533676341.53
    1 JANUARY 2015 03:00. 01:000046 PM - 07:0023.3436434.4345
    JANUARY 2, 2015 05:06.01:000236 AM - 07:00352.3343543.4353
    JANUARY 2, 2015 09:00. 01:000026 AM - 07:00234.453453.54
    3 FEBRUARY 2015 10:00. 01:000026 PM - 07:003423.3534634.45
    FEBRUARY 4, 2015 11:08. 01:000026 AM - 07:00324.3532534534.53

    We have data as above a table and we want to calculate all the days, the hourly average for large data set (almost 100 million).  Is it possible to use the sql functions of analysis for better performance instead of the ordinary average and group of?  Or any other way better performance?

    Don't know if that works better, but instead of using to_char, you could use trunc. Try something like this:

    select
        trunc(some_timestamp,'DD'),
        avg(parameter1)
    from
       bigtable
    where
       some_timestamp between systimestamp-180 and systimestamp
    group by
       trunc(some_timestamp,'DD');
    

    Hope that helps,

    dhalek

  • Monthly average for a given metric

    Hello

    Is it possible to create a widget that would show a monthly average for a given metric?

    Now I have a widget that displays as below:

    Untitled.png

    I would like to network | use Rage (KBps) to show the monthly average and not only value of last probe.

    I use vCAC - 5.8.2 build 1885282

    View widget is available in 6.x, 5.x not. Therefore, the vcops-custom UI would not this widget since it is a web service of legacy 5.x.

  • average for each contragentid

    Hi all! This code works great, it returns the average value for contragentid = 1. So correct result is LUAHPER = 14996837,94

    But when I add the values for contragentid = 2 (see commented strings), my statement returns incorrect result LUAHPER = 5497801,81

    How can I improve my code in order to calculate the average for each contragentid?
    with t as ( 
    
    select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual 
    union all
    select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual 
    union all
    select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual 
    union all
    select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15274795.50 as luah, 215274795.50 as lusd from dual 
    union all
    select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15431807.40 as luah, 215431807.40 as lusd from dual 
    union all
    select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual 
    union all
    select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual
    
    /*union all
    select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual 
    union all
    select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual 
    union all
    select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual 
    union all
    select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215274795.50 as luah, 215274795.50 as lusd from dual 
    union all
    select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215431807.40 as luah, 215431807.40 as lusd from dual 
    union all
    select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual 
    union all
    select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual*/
    ) 
    
    select contragentid, sum(luahper) / cnt as luahper 
    from ( 
     select contragentid, (lead(arcdate,1,date '2011-03-20' + 1) over(order by arcdate) - arcdate) * luah luahper, 
    date '2011-03-20' - date '2011-03-13' + 1 cnt 
    from ( 
    select arcdate, contragentid, luah, lusd 
    from 
    
    t 
    
    where arcdate > date '2011-03-13' 
    and arcdate <= date '2011-03-20' 
    union all 
    select greatest(arcdate,date '2011-03-13'), 
    contragentid, luah, lusd 
    from 
    
    t 
    
    where arcdate = (select max(arcdate) from 
    
    t 
    
    where arcdate <= date '2011-03-13') 
    ) ) 
    where contragentid = 1
    group by contragentid, cnt
    Edited by: 858774 14/06/2011 02:29

    Hello

    858774 wrote:
    But when I add the values for contragentid = 2 (see commented strings), my statement returns incorrect result LUAHPER = 5497801,81

    I guess that's because you don't join and partition on contragentid.
    This appears to do:

    Scott@my10g SQL>/
    
    CONTRAGENTID    LUAHPER
    ------------ ----------
               1 14996837.9
    
    Scott@my10g SQL>l
      1  with t as (
      2  select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual
      3  union all
      4  select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual
      5  union all
      6  select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,14275303.54 as luah, 214275303.54 as lusd from dual
      7  union all
      8  select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15274795.50 as luah, 215274795.50 as lusd from dual
      9  union all
     10  select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15431807.40 as luah, 215431807.40 as lusd from dual
     11  union all
     12  select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual
     13  union all
     14  select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 1 as contragentid,15480730.00 as luah, 215480730 as lusd from dual
     15  --
     16  union all
     17  select to_date('12.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual
     18  union all
     19  select to_date('14.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual
     20  union all
     21  select to_date('15.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,214275303.54 as luah, 214275303.54 as lusd from dual
     22  union all
     23  select to_date('16.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215274795.50 as luah, 215274795.50 as lusd from dual
     24  union all
     25  select to_date('17.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215431807.40 as luah, 215431807.40 as lusd from dual
     26  union all
     27  select to_date('18.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual
     28  union all
     29  select to_date('21.03.2011','dd.mm.yyyy') as arcdate, 2 as contragentid,215480730 as luah, 215480730 as lusd from dual
     30  --
     31  )
     32  select contragentid, sum(luahper) / cnt as luahper
     33  from (
     34   select contragentid, (lead(arcdate,1,date '2011-03-20' + 1) over(partition by contragentid order by arcdate) - arcdate) * luah luahper,
     35  date '2011-03-20' - date '2011-03-13' + 1 cnt
     36  from (
     37  select arcdate, contragentid, luah, lusd
     38  from
     39  t
     40  where arcdate > date '2011-03-13'
     41  and arcdate <= date '2011-03-20'
     42  union all
     43  select greatest(arcdate,date '2011-03-13'),
     44  contragentid, luah, lusd
     45  from
     46  t
     47  where arcdate = (select max(arcdate) from
     48  t t2
     49  where arcdate <= date '2011-03-13'
     50  and t.contragentid=t2.contragentid)
     51  ) )
     52  where contragentid = 1
     53* group by contragentid, cnt
    Scott@my10g SQL>/
    
    CONTRAGENTID    LUAHPER
    ------------ ----------
               1 14996837.9
    

    858774 wrote: How can I improve my code in order to calculate the average for each contragentid?

    When I remove the 'where contragentid = 1' seems to do with above query:

    Scott@my10g SQL>/
    
    CONTRAGENTID    LUAHPER
    ------------ ----------
               2  214996838
               1 14996837.9
    
  • Number of averages for time waveform acquisition

    Hello

    It is on the configuration of the device - settings of the acquisition.

    in the parameters of the collection file, can I know is there a way to feed the number of averages and % of overlap between averages aquire waving time.

    Thank you!!

    BR

    Pattabi

    In version 3.0 of InsightCM, we will support an average and overlap on the data of the spectrum Viewer.  These settings will be applied only to the visualization of the spectral data and will not apply to calculations on the waveform or spectral data form.

    This will meet your needs?  Or are you interested in doing an average and are superimposed on the spectral data to then be used for calculations that are based on spectral data - such as 1 x Magnitude, etc.. ?

    Thanks for the question.

    -alan

  • Create a table in a loop 'for' (reset the number of loops)

    Hello

    I try to incorporate a signal of acceleration from an analog input CRIO to get speed and then further integrate to get the moving of a vibration system.

    I understand that to achieve integration, a table must be fed in. My problem is that I could not buffer the signal in a buffer block, as I couldn't find buffer blocks. so I decided to create my data table by using a loop "for". The nests of the loop 'for' inside a timed loop. The problem that I'm stuck on is how to reset the loop 'for' in order to fill the buffer with each iteration of the outer loop timed.

    I enclose the code if that helps. Note that I use labview in 2013.

    If anyone who has encountered a similar problem before can help me, I would be gratefull.

    Concerning

    Ali

    You can use a shift register initialized as inputs to your curls, to build your table of one. However, you realize, don't you, that the execution of your program as written loops as soon as the computer can spit out responses, then the output array may contain several points that took place before the entry has updated? Assuming that your thing cRIO (I've not worked with these) has integrated into its routine acquisition of calendar data, I suggest you put that inside the loop to get a data point by reading.

    And do you really want your graph to distance for update only every thousand points (points of acceleration million) speed?

    Cameron

  • How to create a control of time for the while loop?

    Hi all

    I want to control my time running of the loop. In other words, I want to stop everything in the execution of the loop after a time (in ms) that is defined by the user. For example user defines Control Panel for 5 seconds before a while loop runs and stops after 5 seconds.

    I don't know is it possible with the while loop. I managed with the timed loop, but this must be wrong with my application. Y at - it of the other loops for timed control if it is not possible with while loop? There is also a simple loop with .vi random number (0-1) as an attachment.

    Best regards

    Jick

    Hi again,

    I managed to solve my problem right after I posted my first message. I did it with the passage of time and the register shift (for the elapsed time of reset).

    Thanks for your replies anyway!

    Best R

    Jick

  • best type of measure daqmx for several closed loop control system

    Hello

    I wonder what kind of type of measure daqmx which are suitable for the control system of closed loop with control about loop 128?

    I design unique loop with continuous sample and sample application. The two correct answer. But I don't know if the control loop number increases.

    Another question is, clock synchronization of time needed for such a system?

    taov,

    I recommend you to use continuous sampling because it is time of material while on demand collection is software time.

    As for the RTOS system, please see this link.

    CarmenC

Maybe you are looking for