Obtaining average values from 2 - 1d arrays

I have 2 1d arrays
The first array contains time values of some length and the second array contains measured values. I would like to find the differences from the measure value array row1 - (minus) row0 / (divide) time array row 1 - (minus) row0 and continue with measure value array row2 - row1/ time array row2 -row1, continuing through the rest of the array.
I have had any good results yeat.
Thanks for your help!

Hi newbie,
that's basic array math:
Message Edited by GerdW on 11-12-2007 01:39 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
calc.png ‏2 KB

Similar Messages

  • Getting int values from a char array

    Hi,
    I need to make a fast program which reads lots of data from files and process them. I need to interpret these data as int's. To be more efficient and avoid to make a lot of disk access, I allocate in memory buffers part of the data, then process it and then allocate new data. The problem is that if I want to allocate data in memory buffers, all the methods that enables me to do that receceive as a parameter only a an array of chars, and as I have mentioned I need to interpret the data as a 4 bytes int. The static methods of Array to get the int value from a position ar not useful because the onlye get the int value of the indexed byte (or char); this method doesn't take 4 bytes from the index to build an int.
    My question is: is there any way to build an int from 4 bytes? or can I get the int's in this way directly from the buffer?
    Thank you,

    Isn't this one of the prime examples of using java.io.DataOutputStream and java.io.DataInputStream?

  • How to obtain Frequency values from Agilent E8361 VNA LV8

    I am migrating code from an Agilent 8722ET VNA to the newer E8361A
    model network analyzer.  The new E8361X library does not have any
    VI that i have found that will actually collect the frequency spectrum
    from this instrument. 
    The save data VI only collects the measurement values and not the x-axis.
    I have tried the method the 87XX vi uses which uses a "OUTPLIML"
    function to obtain the values for a frequency list or log sweep. 
    It does not appear there is a command that is equivalent to this on the E8361. 
    I have attached the code which works for a linear sweep but not for a log one.
    Any help would be appreciated.
    Bryan
    Attachments:
    Read Stimulus Values.vi ‏33 KB

    I have attached a piece of code to do the job. 
    Bryan
    Attachments:
    Read Stimulus Values.vi ‏32 KB

  • How do I hide an indicator if the value from a 1D array is outside set limits

    I have a simple system which takes readings during a lab test from a number of thermocouples. The number varies for each different test and those that aren't used are left dis-connected. I would like my VI to blank off the indicators which aren't used automatically. This could be done by blanking off all inidcators with values above 1000 as the value on screen with no thermocouple connected is 1262. I would like to know how to do this. My system used the sample channel VI to output a 1D array to a digital indicator. I am aware of the hide indicator VI that is available, however that requires a boolean input and I do not know how to convert. Any help would be appreciated.

    You can use comparison functions, that will give you a boolean answer, for example, you can wire equal to function, to a value, wire 1262 to the other input and if equal it will answer TRUE, if not FALSE.
    Hope this helps

  • Averaging values in 2-D Array in a circular area

    I'm trying to average temperature values in a 2-D array, rectangular coordinates, over a circular area.  Is there a sub-array function that works in polar coordinates, that I could utilize?  Any suggestions would be much appreciated.
    Solved!
    Go to Solution.

    Jeff, I think two loops are enough.
    We also should accumulate the sum in a scalar, e.g. as follows, no need to built an array:
    It's less pretty compared to my previous post, because we are flying blind, but operated pretty much "in place". This is good for a "code only" solution, where we don't need visual feedback.
    Or we could only graph the "counted" points as follows:
    Message Edited by altenbach on 07-02-2009 09:14 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    CircularAverage2.vi ‏33 KB
    CircularAverage2.png ‏19 KB
    CircularAverage3.png ‏19 KB

  • Cross checking values from two different arrays

    Hi there,
    I need some help with figuring out how to do this and hopefully someone here can help:
    I've got movieclips of dice called "dicePicked1", "dicePicked2", etc all the way to 6. each of these movieclips has a graphics on keyframes with labels "One" to "Six".
    Now I'm trying to find (in vain) a way to cross check the labels with arrays of numbers so that each time it finds a dicePicked with the appropriate label, it moves onto the next number to find. For example, I need to see if one of each dice has [1,2,3,4,5,6]. Once the program finds a dicePicked with the Label "One", it moves onto the next element which is 2 and so on.
    If it finds the last element (and thus all the elements), it returns true. If it doesn't find an element (for example none of the dicePicked have a Label "Three") then it returns false. I'm trying to find a system that can accommodate different combinations and some with the same numbers multiple times (for example 3 different dicePicked have the label "three")
    I'm having alot of trouble figuring out a good system for this and any help would be awesome!
    Thanks and let me know if anything is unclear!

    Unfortunately, your example lost me on the first roll... I don't see the combination in choosing the 1 and the 5 for 150 points.  That would have me think that the roll with the 4 could be kept for 40 points.  Also, I didn't see where getting a 5 or a 1 for the last roll would have yielded something.
    Anyhow, if you look at what I did for the Yahtzee game, each possible combination has a function dedicated to testing for it.  The difference with Yahtzee being that you have to choose which scoring element you use up for each turn, whether you earn that scoring element or forfeit it.  Also keep in mind that I created that tangle of code when I was a youngin' in the programming realm, so there may be cleaner ways of dealing with things.
    Since you appear to be automating the scoring process, you likely need to have something first detect that the "hold these" action has taken place and then do some evaluation on those held thru a top-down series of checks (meaning highest scoring combinations to lowest), and accept the first that fills the bill.  I don't understand the logic as to why a 1 and a 5 score anything, but in any case, your code would need to have a test for that scenario.  And if having the last die be a 1 or a 5 also scores, then you would need to retain something relative to that relkating to the 1 and 5 being selected earlier.

  • Get numerical values from 2D array of string

    Hello! 
    I start by saying that I have a base knowledge of LabView. I'm using LabView 2011. I'm doing some communications test via Can-Bus protocol. As you can see in pictures of the block diagram and of the front panel that I've attached I'm using "Transmit Receive same Port" LabView example. It works very good but I would need to insert the 8 data bytes that I receive from the server in 8 different numerical variables so that I could use them to make some operations. How can I get numerical values from the 2D array of string that I attached? 
    Every example that you can provide is important! 
    Thank you very much! 
    Attachments:
    1.jpg ‏69 KB
    2.jpg ‏149 KB

    Hi martiflix,
    ehm: to unbundle data from a cluster I would use the function Unbundle(ByName)…
    When you are new to LabVIEW you should take all the FREE online resources offered by NI on their website!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • To obtain values from fields in a web page.

    Hi everyone,
    I am in the process of developing a web based application. I am able to
    successfully convert my windows to web page documents.
    I have sincerely followed the prescribed steps to be adopted in building
    methods for validations and processes, so as to utilise them for my web
    pages too.
    But the problem that I am facing is to obtain values back from the web
    page fields (user entered values) for performing validations.
    Unfortunately the explanations provided in the Forte Web SDK Manual
    for obtaining the values from the web page fields and load it on to the
    source window through LoadParameters() method (a method in the window
    converter class of HTMLWindow project) seems to be inadequate.
    If some one can site the steps that Iam probably missing or some
    examples, it will be of great help.
    Thanks in advance.
    Pamella.
    Get Your Private, Free Email at http://www.hotmail.com

    Hi Dan,
    Thanks for your assistance.
    But as regards to my application, I have an existing forte application
    which Iam trying to web enable.
    To summarize my problem let me just consider the openning window (logon
    screen) which I have converted to web page using WindowConverter Class
    in the HTMLWindow project (obviously, it is my supplier project). The
    functionality of this window class has to just accept the user name and
    validate it. If the user name is valid then proceed further else
    display an error message. I have a separate validation method for the
    user name, which I can utilise to validate the user name typed by the
    user on the web page, if Iam browsing or on the window, if Iam directly
    running the application.
    The widgets on the window are <UserId> and <ProceedButton> with
    window attribute names as UserId and ProceedButton respectively.
    Now my handle request method goes like this :
    -- This method is the entry point from the Internet to my
    -- application. It is automatically called when a request
    -- from the Web arrives.
    response : HTTPResponse = new;
    -- Find the page name.
    pageName : TextData = new;
    pageName.SetValue(request.PageName);
    -- Generate response pages.
    if pageName.IsEqual('processquery',IgnoreCase=TRUE) then
    -- Please note that I have not write any HTML to build my web page.
    -- Instead Iam using the WindowConverter Class to convert my existing
    -- windows on the fly to web pages during run time.
    w : LogonWindow = new;
    -- my logon window class
    Converter : WindowConverter = new(sourceWindow=w);
    Converter.AssignButton(sourceField = w.<ProceedButton>,type =
    'submit');
    loginURL : TextData = self.CGIURL.Clone(deep=TRUE);
    loginURL.Concat('?serviceName=').concat('appweb');
    loginURL.Concat('&pageName=PwdPage');
    w.<ProceedButton>.HTMLLink = loginURL.value;
    -- Proceed button is on my window to which
    -- I have associated the above HTMLLink
    -- This link does not submit the User Name typed by the
    -- User browsing my web page, but this User Name has to
    -- come as part of the request from the browser to perform the
    -- validation, as Iam not sure about obtaining the User name
    -- from the web page.
    -- My problem is how to get this user name????????
    html : HTHtml = new;
    head : HTHead = new;
    body : HTBody = new;
    -- Give the page a title.
    head.Add(HTTitle(Text='Application For The Web'));
    html.Add(head);
    form : HTForm = New();
    body.Add(Converter.WindowToForm(Action=self.CGIURL,HTMethod='POST'));
    html.Add(body);
    response.AssignResponse(html.ConvertToString());
    elseif pageName.IsEqual('PwdPage',IgnoreCase=TRUE) then
    w : LogonWindow = new;
    Conv : WindowConverter = new(sourceWindow=w);
    button : PushButton = new();
    button = Conv.LoadParameters(request,w.<UserId>);
    -- This will fail because the 'Request' has no user Id.
    -- Here, the explanation provided in the Forte Web SDK manual for
    -- LoadParameters method (method from WindowConverter Class) seems to
    -- be inadequate.
    If w.UserId <> Nil And w.UserId.Value <> '' And w.UserId.LengthToEnd()
    0 ThenIf SQLsSO.IsValidUserId(w.UserId) Then
    -- Method to validate the user Name.
    w1 : PasswordWindow = new;
    Converter : WindowConverter = new(sourceWindow=w1);
    Converter.AssignButton(sourceField = w1.<ProceedButton>,type =
    'submit');
    pwdURL : TextData = self.CGIURL.Clone(deep=TRUE);
    pwdURL.Concat('?serviceName=').concat('appweb');
    pwdURL.Concat('&pageName=MessagesPage');
    -- and here I will have to get the password typed in by the User.
    -- once again my same problem?????
    w1.<ProceedButton>.HTMLLink = pwdURL.value;
    html : HTHtml = new;
    head : HTHead = new;
    body : HTBody = new;
    -- Give the page a title.
    head.Add(HTTitle(Text='Application For The Web'));
    html.Add(head);
    form : HTForm = New();
    body.Add(Converter.WindowToForm(Action=self.CGIURL,HTMethod='POST'));
    html.Add(body);
    response.AssignResponse(html.ConvertToString());
    Else
    -- Generate an exception for unknown page.
    .............. and etc.
    In your example, you had sighted about the 'Junktxt'. How does it comes
    as part of the request from the browser and what is the reference
    associated with the submit button?
    If you need further clarifications, please write to me. Iam also still
    working on it.
    Thanks in advance,
    Pamella.
    You Wrote :
    Hi, Pamella --
    It might be easier to help if you could be a little more specific about
    what went wrong (ie, the problematic code snippet and the resulting error
    message), or what exactly you were trying to do. In any event, it is very
    easy in WebEnterprise to pass values up to Forte from web pages. You can
    embed them in HTML "hidden" tags or they can accompany standard form
    elements.
    For instance, say you have the following HTML code ...
    <form method="POST" action="$$FORTE.ExecURL">
    <input type="hidden" name="ServiceName" value="TestService">
    <input type="hidden" name="TemplateName" value="nextpage.htm">
    <input type="hidden" name="hiddenParam" value="dog">
    <div align="center"><center>
    <p>
    Type some junk here: <input type="text" name="junkTxt" size="20">
    </p>
    </center></div>
    <div align="center"><center>
    <p>
    <input type="submit" value="Submit" name="submitBtn">
    <input type="reset" value="Reset" name="resetBtn">
    </p>
    </center></div>
    </form>
    In addition to what the user types into the text box (junkTxt), say you want
    to pass "dog" up to Forte as a hidden parameter (hiddenParam) (hey, done't
    ask me why!). You can retrieve these values up in Forte in the HandleTag
    method of your scanner service by invoking "FindNameValue" on
    request:HTTPRequest, ie
    firstItem:TextData = request.FindNameValue('junkTxt');
    secondItem:TextData = request.FindNameValue('hiddenParam');
    firstItem now contains the value of "junkTxt" and secondItem contains
    "dog." You can now do whatever you like with these guys, including putting
    them in a ResultSet to be displayed on "nextpage.htm"
    Hope this helps,
    Dan______________________________________________________
    Get Your Private, Free Email at http://www.hotmail.com

  • Passing values from method array to class array

    HELP!! Plz excuse any ignorance. Am a noob and have created an array within my class. I then try to alter those array values from inside one of the classes methods. When I try to access the new values from the class array, they don't exist. I think it's a duration/scope issue and am struggling to get around it. This is the only way I can implement the task required and would appreciate any advice you can thorw. cheers in advance.. =~D

    I suspect that you're altering an array passed as a parameter, rather than array that's a field of the instance, but as you didn't post any of your code, that can only be a guess.

  • Display sound data value from ByteArrayOutputStream

    hi People,
    Can advise what is the function that i can use to retrieve or display the data that i stored in ByteArrayoutputStream buffer?
    So far i can only store the data in... but how can i retrieve and display them on output panel?
    Many Thanks

    Hi again,
    I have modify my code and found the error.. But this time i can't display the value correctly. Please advise...
    //This method captures audio input from a microphone and saves it in a ByteArrayOutputStream object.
    private void captureAudio(){
    try{
    //Get and display a list of available mixers.
    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
    System.out.println("Available mixers:");
    for(int cnt = 0; cnt < mixerInfo.length; cnt++){
    System.out.println(mixerInfo[cnt].getName());
    }//end for loop
    //Get everything set up for capture
    audioFormat = getAudioFormat();
    DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class,audioFormat);
    //Select one of the available mixers.
    Mixer mixer = AudioSystem.getMixer(mixerInfo[3]);
    //Get a TargetDataLine on the selected mixer.
    targetDataLine = (TargetDataLine)mixer.getLine(dataLineInfo);
    //Prepare the line for use.
    targetDataLine.open(audioFormat);
    targetDataLine.start();
    //Create a thread to capture the microphone
    // data and start it running. It will run
    // until the Stop button is clicked.
    Thread captureThread = new CaptureThread();
    captureThread.start();
    } catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    }//end catch
    }//end captureAudio method
    public int[] ConvertSoundData (byte[] SoundData, int SampleTotal){
    //Determine the original Endian encoding format
    boolean isBigEndian = audioFormat.isBigEndian();
    //this array is the value of the signal at time i*h
    int x[] = new int[SampleTotal];
    int value;
    //convert each pair of byte values from the byte array to an Endian value
    for (int i = 0; i < SampleTotal*2; i+=2) {
    int b1 = SoundData;
         int b2 = SoundData[i + 1];
         if (b1 < 0) b1 += 0x100;
         if (b2 < 0) b2 += 0x100;
         //Store the data based on the original Endian encoding format
         if (!isBigEndian) value = (b1 << 8) + b2;
         else value = b1 + (b2 << 8);
         x[i/2] = value;
    return x;
    //This method creates and returns an
    // AudioFormat object for a given set of format
    // parameters. If these parameters don't work
    // well for you, try some of the other
    // allowable parameter values, which are shown
    // in comments following the declartions.
    private AudioFormat getAudioFormat(){
    float sampleRate = 8000.0F;
    //8000,11025,16000,22050,44100
    int sampleSizeInBits = 16;
    //8,16
    int channels = 1;
    //1,2
    boolean signed = true;
    //true,false
    boolean bigEndian = false;
    //true,false
    return new AudioFormat(
    sampleRate,
    sampleSizeInBits,
    channels,
    signed,
    bigEndian);
    }//end getAudioFormat
    //=============================================//
    //Inner class to capture data from microphone
    class CaptureThread extends Thread{
    //An arbitrary-size temporary holding buffer
    byte tempBuffer[] = new byte[10000];
    public void run(){
    byteArrayOutputStream = new ByteArrayOutputStream();
    stopCapture = false;
    try{//Loop until stopCapture is set by another thread that services the Stop button.
    while(!stopCapture){
    //Read data from the internal buffer of the data line.
    //targetDataLine.read(byte[] b, int off, int len)
    int cnt = targetDataLine.read(tempBuffer, 0, tempBuffer.length);
    if(cnt > 0){
    float sample_rate = audioFormat.getSampleRate();
    float T = audioFormat.getFrameSize() / audioFormat.getFrameRate();
    int n = (int) (sample_rate * T ) / 2;
    System.out.println(n); ---------> to print the number of sample
    //Save data in output stream object.
    byteArrayOutputStream.write(tempBuffer, 0, cnt);
    int[] SoundData = ConvertSoundData(tempBuffer,n);
    for(int index = 0; index < SoundData.length; index++){
    System.out.println(index + " " + SoundData[index]); ----------> to print the ALL sound data in the returned array.
    }//end if
    }//end while
    byteArrayOutputStream.close();
    }catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    }//end catch
    }//end run
    }//end inner class CaptureThread
    The result i got during i sing "hmmm" to my microphone is as below:
    1
    0 1281
    1
    0 61184
    1
    0 24830
    1
    0 25598
    1
    0 33279
    1
    0 25350
    1
    0 19728
    1
    0 54537
    Below is my question:
    1) Why the number of sample keep on remained as 1? Since the sampling frequency is 8000Hz..
    2) Why my index variable remained as 0? I suppose i will have 8000 values since my sampling rate is 8000Hz... Is it impossible to print 8000 data within 1 sec?
    Is it advisable if i transfer the obtained numeric array directly for FFT analysis?
    (I wish to do a real time frequency analyzer. With MATLAB, I can only do an analyzer by retrieving the .wav data content.)
    I am shame to say i am still not clear enough with the sampling and data retrieve algorithm. Thats why i will have difficulties to delliver correct idea.
    Appreciate if you have any tutorial can share with me so that i can understand more.
    Thank you again.

  • How to lookup a value in a 2D array from an Excel file - Dasylab version 12 Pro

    Hi, I am new to this forum and am looking for some advice on a worksheet I'm trying to construct.  I have an Excel spreadsheet that is basically a 2D array, and I want to use Dasylab v12 Pro to be able to import a value from this array based on user selections from within the Dasylab worksheet.
    Column A lists 200+ diesel engine models.  I've shown 9 in my Excel attachment...one model per row (shaded in yellow), and each engine model can be run at several speeds (shaded green in columns B thru F).  For an engine in a given row, combined with a chosen operating speed gives you a corresponding horsepower (blue shading).
    I have this Excel sheet saved somewhere on my C:/ drive, and what I want to do is when the user starts the Dasylab worksheet he will select from a drop drown menu to choose the engine model (ie A, B, C, etc) and another drop down menu to choose the speed (ie 1470, 1760, etc).  I know that I can make a drop down menu with a Coded Switch within Dasylab, however it seems only 16 choices can be made from each switch, so for my 200 engine models I will need 13 switches!  I know I can assign a text description like "Engine A" to a numerical value within that coded switch.  Somehow I need to take those two selections made within the Dasylab experiment, and read this Excel file (ie my database of all of these 200 diesel engine models) as a 2 dimensional array by row and column to spit out the data value (the blue numbers) back into Dasylab.
    The goal is to take the engine model, speed, and the horsepower obtained from the array search and write these to an .asc file that I will create a running log of this data.  So, after the test page is run 50 times it will have 50 rows of data containing these 3 parameters.  There is some other test data taken from my data acquisition that goes along with this, however that's not part of my 2D array predicament.
    I'm taking a guess that I need to do something with global strings & variables, and some how import them and export them with an ODBC in/out module.  This is something I've just never worked with before so I am a bit lost.  Obviously I can just make the user type in the engine model and speed as a startup parameter at the start of the test and save that to a variable or string, but I want to make it idiot proof so that the two selections (ie row and column) can be chosen from a pre-set list and will yield my data value.  Everything else related to Dasylab I am pretty proficient with.
    Thanks,
    Mike
    Attachments:
    engine 2D array.xlsx ‏10 KB

    This would be the best way.
    Also, with version 13 they started using Phyton to create custom modules that can be programmed in DASYLab.
    We arte learning this right now and I know that you can use standard message dialogs with that as well.
    I would suggest to you to download a demo of V13 and take a look at the Pyton module.
    Also, usually DASYLab system intgretors like us, can provide services also on things like this including Excel programming for pre and post analisys 
    Tom Rizzo
    InSyS Corp.
    www.insyscorp.com
    Your DASYLab integrator

  • How to make labview program to get average value of 200 reading from multimeter (by using loop)

    Hello
    How to make labview program to get average value of 200 reading from multimeter (I using using loop) to read voltage from mulmeter  but I like to get average value of all of 200 reding how can I do that?
    Thanks
    Wee
    Solved!
    Go to Solution.

    Another idea with less programming - take advantage of the "free" array that comes with a Chart - i.e. the  History Data.
    1) Wire your DMM data to a Chart. (You can set the chart to invisible if you don't plan on using it in the GUI).
    2) Set the Chart History Length to 200 (right click on the chart, click on Chart History Length...)
    3) On the block diagram, use the History Data Property Node, wire it to Mean.vi, and you're done.
    Easiest running average ever.
    Message Edited by Broken Arrow on 04-07-2010 11:36 AM
    Richard
    Attachments:
    EasyAvg.jpg ‏8 KB

  • Finding the smallest value from an array

    Hi there :)
    I started learning Java a few days ago and have now run into my first problem :p
    I am using Netbeans on Mac OS X.
    I need to find the smallest value from an array. So far I've had no luck. Any suggestions would be fantastic.
    The code so far:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
            int O = A.length - 3;
            int B = A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7] + A[8] + A[9] + A[10] + A[11] + A[12] + A[13] + A[14];
            A[15] = B;  // Stores the sum of the integers in A[15]
            int C = B / O;
            A[16] = C;  // Computes and stores the average in A[16]
            int D = 101;
                if (A[0] < A[1]) { D = A[0]; }
                else { D = A[1]; }
                if (A[1] < A[2]) { D = A[1]; }
                else { D = A[2]; }
            System.out.println("There are " + O + " numbers in the Array");
            System.out.println("Those numbers add up to " + B + ".");
            System.out.println("The average of those numbers is " + C + ".");
            System.out.println("The smallest value in the array is " + D + ".");
    }The code is incomplete, but it works so far. The problem is I know there must be an easier way. SAVE ME :)

    OK :)
    Just thought I should show you the output as to help anyone else with the same problem:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17                           // COMPLETED
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    import java.util.Arrays;
    public class Main { 
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
         public static void main(String[] args) {
                  int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
              Arrays.sort(A);
              System.out.println("The smallest value in the array is " + A[0] + ".");
              int num = A.length;
              System.out.println("There are " + num + " values in the Array.");
              int sum = 0;
              for (int i = 0; i < A.length; i++) {
                   sum+=A;
              System.out.println("Those numbers add up to " + sum + ".");
              double d = (double)sum/num;
              System.out.println("The average value of those numbers is " + d + ".");
    What Iearned:
    1) How to create for loops properly
    2) How to import java.util.Arrays ( =D )
    3) How to get a more accurate average using double instead of int
    4) This forum is the best and has very helpful people 24/7 ( =D)
    Thanks Again,
    Mo.

  • Color value from an "Average Blur" applied to a selection

    Hello,
    I would like to obtain the color value from an Average Blur applied to a selection.
    Any ideas ?
    Thanks

    Step by step before question :
    1) make a Merged Stamp
    2) make a Selection with Lasso
    3) Filter > Blur > Average
    Well, at this point of process, i would like to obtain the color value created by the Average filter.
    All that with scripts, i forgot to mention that
    Any suggestions ?

  • Assigning Values from a file to an Array

    hey everyone I am working on a program that inputs values from a text file into an array i got the first array to work but the second array does not work. Please if you have a moment lend a hand. Here is my code. the program compiles fine but will not run right with the second array in it. The second array is called "B"
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    class algorithmAssignment1{
         public static void main (String[] args)throws IOException{
         int mark, counter, arrayAsize, mark2;
         counter=0;
         arrayAsize=100;
         int [] A= new int[arrayAsize];
         int [] B= new int[arrayAsize];
        String fileName = "arraynumbersa.txt";
        String value,value2;
        BufferedReader input;
        input = new BufferedReader (new FileReader (fileName));
        value = input.readLine ();
       while (value != null){
           mark = Integer.parseInt (value);
           A[counter]=mark;
           counter=counter+1;
           value = input.readLine ();
      /*  String fileName2 = "arraynumbersb.txt";
        BufferedReader input2;
        input2 = new BufferedReader (new FileReader (fileName2));
        value2 = input2.readLine ();     
         while (value2 != null){
           mark2 = Integer.parseInt (value2);
           B[counter]=mark2;
           counter=counter+1;
           value2 = input2.readLine ();
         bubbleSort(A,A.length);
         bubbleSort(B,B.length);
         System.out.println("Here is list A");
         for (int i = 0; i < A.length; i++){
             System.out.println( A[i] );
        System.out.println();
        System.out.println("Here is list B");
        for (int i=0;i<B.length;i++){
             System.out.println(B);
    /*change
    for (int i=0;i<A.length;i++){
         for (int j=0;j<B.length;j++){
              if (A[i]==B[j]){
                   System.out.println("Numbers that are in list A and B are "+ B[j]);
    static void bubbleSort(int numbers[], int array_size){
         int i, j, temp;
         for (i = (array_size - 1); i >= 0; i--)
         for (j = 1; j <= i; j++)
         if (numbers[j-1] > numbers[j]){
         temp = numbers[j-1];
                             numbers[j-1] = numbers[j];
                             numbers[j] = temp;

    Ok new problem now. I have to get the duplicates to go into a new array in order to display the duplicates. I can't figure out why it just lists the one duplicate but not the others.(It lists the final duplicate)
    Here is my code:
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    class algorithmAssignment1{
         public static void main (String[] args)throws IOException{
         int mark, counter, arrayAsize, mark2,counter2;
         counter=0;
         arrayAsize=100;
         counter2=0;
         int [] A= new int[arrayAsize];
         int [] B= new int[arrayAsize];
         int [] C=new int [arrayAsize];
        String fileName = "arraynumbersa.txt";
        String value,value2;
        BufferedReader input;
        input = new BufferedReader (new FileReader (fileName));
        value = input.readLine ();
       while (value != null){
           mark = Integer.parseInt (value);
           A[counter]=mark;
           counter=counter+1;
           value = input.readLine ();
        String fileName2 = "arraynumbersb.txt";
        BufferedReader input2;
        input2 = new BufferedReader (new FileReader (fileName2));
        value2 = input2.readLine ();     
         while (value2 != null){
           mark2 = Integer.parseInt (value2);
           B[counter2]=mark2;
           counter2=counter2+1;
           value2 = input2.readLine ();
         bubbleSort(A,A.length);
         bubbleSort(B,B.length);
         System.out.println("Here is list A");
         for (int i = 0; i < A.length; i++){
             System.out.println( A[i] );
        System.out.println();
        System.out.println("Here is list B");
        for (int i=0;i<B.length;i++){
             System.out.println(B);
    for (int i=0;i<A.length;i++){
         for (int j=0;j<B.length;j++){
              if (A[i]==B[j]){
                   for (int k=0;k<C.length;k++){
                        C[k]=(B[j]);
                   System.out.println("Here"+B[j]);
    System.out.println("Here are A and B");
    for (int i=0;i<C.length;i++){
         System.out.println(C[i]);
    static void bubbleSort(int numbers[], int array_size){
         int i, j, temp;
         for (i = (array_size - 1); i >= 0; i--)
         for (j = 1; j <= i; j++)
         if (numbers[j-1] > numbers[j]){
         temp = numbers[j-1];
                             numbers[j-1] = numbers[j];
                             numbers[j] = temp;

Maybe you are looking for