Average values of a 2-D array
Hi folks,
quite simple question, just want a simple solution. I've got a 2-D x*y array, need the average value of all the y volume numbers, which means eventually I will have a x*1 1-D array. Is there any simple solution instead of 2 loops? Cheers.
Here is an example with a switch for row or column averaging. The TRUE case of the case statement contains a Transpose 2D Array.
If you want to average the whole array, you can do this easily by using Reshape Array, then Mean.vi. Here is that example.
Message Edited by DFGray on 10-28-2009 07:39 AM
This account is no longer active. Contact ShadesOfGray for current posts and information.
Similar Messages
-
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 -
the data I measured changed rapidly, so i want get the average value of the data
Do not tell me to use mean.vi , i have already know that.
and i got an idea which is add the data into an array every time, then sum of all the data value and take the result divide by the number of elements
but i dont know how to achieve that, anyone can build a simple vi to show me ? thank you
i have attached my vi which is using mean.vi to calc the average value, you can delete it and using in your way , thank you !
Solved!
Go to Solution.
Attachments:
EN-new.vi 274 KBHi I got a similar issue for averaging. I used the mean.vi from the math function but the average is rolling when i run it. I am trying to calculate the average for the data i read to the RT FIFO (which is around 40000 lines).I got the writing part working, however, when i am reading the data, I couldn't get it working. I thought i read the data as a 1-D array, and then pass it to the Mean.vi and then got the result. But seems like the mean is only showing the last data in the array.
Can someone help me with this??
Attachments:
FPGA-vi.png 242 KB
RT-vi.png 182 KB
RT-2mod.vi 515 KB -
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 -
I'm trying to take a few readings from an oscilloscope. I made a simple VI to test all of the parameters for the oscilloscope and make sure that everything was working before implementing the oscilloscope in a much more elaborate VI. I want to have voltage at a certain level (say, 2 V) then take a reading from the oscilloscope, add that value as a new element in an array. After doing this 100 times the VI will add the average value to a spreadsheet and then increase the voltage (to 2.05 V or something) and take 100 more measurments and average/record them. I was able to take ten sets of 100-sample averages and write them to an array (see notbroken.png) on one file, but when I try to do it in the real program (see broken.png) I check my spreadsheet and each entry is "0.000." Note that I've also created a program that controls the power supply independently and verified that I know how to control it properly; in fact, the only non-zero column is the one which reads the voltage that the program is telling the power supply to output.
I've literally written out each step that my "not broken" program does to find the average value and then done the same for the broken program and I can't find a single discrepancy. Any and all help would be greatly appreciated!
Solved!
Go to Solution.
Attachments:
broken.png 53 KB
notbroken.png 42 KBvweltin wrote:
I've literally written out each step that my "not broken" program does to find the average value and then done the same for the broken program and I can't find a single discrepancy. Any and all help would be greatly appreciated!
Here's an exact analysis.
Both of your programs are broken, but the one with the FOR loop iterates only 10 times, thus you get arrays with one nonzero value (the last one) when the loop terminates. (Just because the average is nonzero, does not mean it is correct!)
Your code with the while loop iterates 11 times, but your array only has 10 elements, meaning that in the last iteration you try to replace an element that does not exist and the array remains at all zeroes.
In both programs, there will never be more than one non-zero element in the array.
LabVIEW Champion . Do more with less code and in less time . -
Averaging values of multiple signals seperately
Hi All,
I am attempting to create a VI that will average data over a user defined amount of time (via boolean switch). The attached vi collects data once the "collect Data" switch has been triggered, when the test is over the user triggers the "average collected data" switch to get an averaged value. Please see attached VI.
THis vi works fine for a single signal. However, the ultimate goal is to be able to do this whole process for n-number of sensors throughout my test loop with a final output as an excel file.
I am pretty sure that I can get the data saved for an excel file but I cant figure out how to get all of the signals averaged seperately and placed into an array.
Any help will be much appreciated!
Thanks,
Stefan
Attachments:
Average Collected Data.vi 13 KBStefan,
When you are doing the multiple signal process, will the collection time and averaging be done for all signals simultaneously or will there be separate Collect and Average controls for each channel?
If all channels will be done simultaneously, you can probably just make your arrays 2D with each channel in a different column. Each iteration of the loop will store the data in the next row (if Collect is True).
Notes on your VI: 1. You do not need the sequence structure. Dataflow controls when things happen. Your VI will work the same without it.
2. The two case structures wired to Collect Data could be combined into one.
3. Building an array inside a loop results in frequent memory reallocations. As the array gets large this will cause the program to slow down and will fragment memory. A better approach is to allocate memory outside the loop with Initialize Array and use Replace Array Subset inside the loop where the Build Array primitives are now. You will need to add another shift register to keep track of the next index to replace.
4. Loops should usually have a time delay to prevent them from grabbing all the available CPU cycles. Once you put in a real data acquisition process, that may provide the delay.
Lynn -
I'm quite new to LabVIEW (v.8.0) and I'm trying to figure out the easiest way to have a 4-element array multiplied by its inverse values resulting in a 16-element array
Array 1 values = 1, 2, 3, 4
Array 1 inverse values = 1, 0.5, 0.33, 0.25
Resulting array = (1, 0.5, 0.33, 0.25, 2, 1, 0.66, 0.5, 3, 1.5, 1, 0.75, 4, 2, 1.32, 1)
Any advice would be appreciated. Thanks!
Solved!
Go to Solution.Attachments:
mo.doc 27 KB -
To display average value in a graph
Hi There,
In one graph I need to display the duration for each week as per the week range selected and a separate average duration value of the weeks selected.
Is it possible to develop a query for above average value and use this query in WAD?
Can anybody help in providing a solution
Thank you
AnimaBI Query data can be fed directly to WAD Charts.
See below.
http://help.sap.com/saphelp_nw04/helpdata/en/0c/95c83956852b51e10000000a114084/content.htm -
Assigning value to a two dimensional array
Hi,
I am trying to assign value to a two dimesional array the following way.
String [ ] [ ] d2D = new String [10] [ ];
for (int i = 0; i<obj.length; i++){
d2D = { "hello " + i, "here" , "we go" };
but it gives me the error "illegal start of expression " pointing to the line in the loop assigning values to d2D[i].
Any help would be deeply appreciated.You need to use the syntax for creating an anonymous array: new String[] {..., ...}
String [ ] [ ] d2D = new String [10] [ ];
for (int i = 0; i<obj.length; i++){
d2D[ i ] = new String[] { "hello " + i, "here" , "we go" };
} -
Too many decimals in Average value
Hi
I am using Report Builder and the wizard do design a table which i deploy as a .jsp page.
For some columns in the table I select to display the average values. Some of the values looks fine with one decimal as i want, but some values is displayed with a lot of decimals (about 10) as 164,346666666666666666. I have tried to change the length but without effect. Are there any possibility to decide the number of digits to be shown in the report . Or is i it a bug in Report Builder.Go to Property Inspector of the field and choose the right "Format Mask".
-
Creating function to calculate average value
Hi,
The below query was successfully return an average value. It returned 1 row.
SELECT AVG(Volume)
FROM security
WHERE
Type = 'Future' AND
Rating = 'AAA' AND
Code = 1 AND
(Day = ''14-mar-09' OR
Day = '16-mar-09' OR
Day = '');
I tried to use that function on my created function below.
CREATE OR REPLACE FUNCTION fn_Vol_Average
( v_DayLast_1_Week IN DATE,
v_DayLast_2_Week IN DATE,
v_DayLast_3_Week IN DATE )
RETURN NUMBER IS
v_Vol_Average NUMBER;
BEGIN
SELECT AVG(Volume) INTO v_Vol_Average
FROM security
WHERE
Type = 'Future' AND
Rating = 'AAA' AND
Code = 1 AND
(Day = v_DayLast_1_Week OR
Day = v_DayLast_2_Week OR
Day = v_DayLast_3_Week);
RETURN NVL(v_Vol_Average, NULL);
END;
I called that function by the following query. it was work, however it return the whole rows. It looks like the function perform the average calculation of each rows on the table.
Can anyone help me what is going on with the logic?
select fn_Vol_average('14-mar-09','16-mar-09','')
from security
--But since your function calculates the average over the whole security table, you wouldn't call this from a select statement which also reads the security table.
You just want to execute it once.
declare
l_vol_average number;
begin
l_vol_average := fn_Vol_average('14-mar-09','16-mar-09','');
dbms_output.put_line(l_vol_average);
end;By the way, be careful with your date parameters. You should use TO_DATE with a proper format mask to prevent conversion errors. -
How can i save the values of output waveform in array ?
hi
how can i save the values of output waveform in array ?how can i save the values of output waveform in array ?
the program is attachment bellow
Attachments:
closed loop transfer fn+fuzzy.vi 28 KB -
Count the number of values in a two dimensional array
i am trying to figure out how to count the number of values in a two dimensional array.
numScores = student[i][j].length;This doesn't work, i am trying to find a way of counting the columnsObject[][] o;
int tot = 0;
for(int x = 0 ; x < o.length ; x++)
tot += o[x].length;
}If it's not a jagged array, however, this would be easier:
int tot = o.length * o[0].length; -
Display of "Average Values Text in ALV grid"
Hi
I use ALV grid to display the fields from a table. I have 15 columns. I need to do average for four columns.
In the field catalog i did a do_sum for those fields.
When the ALV grid is displayed I get average values for these columns.
Eg. Let suppose the grid looks like
Field1 Field2 Field3 Field4 Field5 Field 6.
vendor1 18 22 6 17 28
vendor1 54 11 16 62 28
vendor1 33 21 26 79 18
35 18 16 52 24
My requirement is I need to display the text "AVERAGE VALUES" . ( I need something like this.)
Field1 Field2 Field3 Field4 Field5 Field 6.
vendor1 18 22 6 17 28
vendor1 54 11 16 62 28
vendor1 33 21 26 79 18
Average values 35 18 16 52 24
Could someone help me in this?
Thanks & Regards
KavithaHello,
you can use event subtotal_text of ALV_GRID.
Regards,
Pedro Santos -
Calculate Average value based on Day ??
Hello,
I am trying to calculate the Average value based on a day. The data is presented as follows...
Day SOCount
Mon 34
Mon 56
Mon 67
Tues 24
Tues 25
Tues 23
Weds 45
Weds 69
The issue im having is that the Day column needs to be grouped first and the SOCount sumed together. Then the Average SO Count needs to be calculate based on this.
ThanksThanks for the reply,
The solution you have provided only gives me the average of the count of the SO Count, not the actual average of all the values added together then divided by the count..
The report i am creating only has charts in it. So i am trying to create a chart showing the
Average Sale Order Value by day.
I should have metioned this from the start, sorry.
Is it possible to do ?
Edited by: davitali on Nov 4, 2011 6:32 AM
Maybe you are looking for
-
Hi, let me know which solution option i wish to pursue: 1. The fix for unpublished Bug 5160122 "TEXT QUERY DEADLOCK WITH GATHER_STATS_JOB, THEN COREDUMP ORA-7445 [DREXUMCX]" is included in Oracle RDBMS 11.1.0 and newer. In Oracle RDBMS 11.1.0 and new
-
Display Issues with Mac Pro 1.1 HELP!!
I have a Mac Pro 1,1: Model Name: Mac Pro Model Identifier: MacPro1,1 Processor Name: Dual-Core Intel Xeon Processor Speed: 2.66 GHz Number Of Processors: 2 Total Number Of Cores: 4 L2 Cache (per processor): 4 MB Memory: 4 GB Bus Speed: 1.33 GHz Boot
-
Oracle direct path read IO size
Hello! I am confused a little with IO size. I am running 11.2.0.3 on Oracle Linux x64 6.2. Block_size=8K, MULTIBOCK_READ_COUNT=128 Database is Single Instance and is using ASM grid. ASM AU =1M As a test I am running a simple query against large table
-
I have reset the ipod twice, connected to my computer and Itunes, synced the device, yet it remains stuck in disk mode.
-
Tiny iWeb slideshow in iWeb 08
Hello, I just upgraded to iWeb 08 and realized that the former slideshow function on photo pages (black background with reflection) now shows very small versions of my photos, more like thumbnails than the actual photos, and in any case much smaller