MATLAB: Analysing data that meets conditions

discretisinglarge data

Hi all,
I am trying to analyse data from an FEM software. The data relates to node positions and then a velocity value [x,y,u].
I am trying to analyse sectors of the 2D domain which is 5000m x 2000m.
For each sector I want to analyse a 1m x 113m area and then average all the nodes within that sector to form an overall u.
I don't quite know how to tackle this problem, I have been trying for a few days and can't quite get the scripts to work.
I specifically want to know if it is possible to scan through data looking for specific nodes which are within (1 <= x <= 2),(10<=y<=123) and then average them and then start building up a library of u values for each sector.
I would greatly appreciate anyones input.
Kind Regards,
Christopher

Best Answer

"I specifically want to know if it is possible to scan through data looking for specific nodes which are within (1 <= x <= 2),(10<=y<=123) and then average them...
Presume you've read the file and have the 2D array data
idx=iswithin(data(:,1),1,2) & iswithin(data(:,2),10,123); % select the condition; idx-->logical
means=mean(data(idx,:)); % average over each column of those values (*)
(*) I don't know for certain what "them" above refers to, specifically, so I just averaged all four columns of data for the selected combination of x/y coordinates including the coordinates.
iswithin is my helper function (a little syntactical sugar to make the higher level code a little more legible; it's nothing fancy) --
>> type iswithin
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
>>
Put it in an m-file named iswithin.m and somewhere on the Matlab path matlabpath -- I have a "utilities" subdirectory for such generally useful things.