Create matrix of z values from unique x and y in data structure with unsorted x's and y's
1 回表示 (過去 30 日間)
I have a data structure with more then 2 columns in it. The first 2 columns are sweep values which when combined make a unique pair. For example I could sweep paramater a from 1:3 and parameter b from -100:10:-80 then measure something/s at each place and create a data structure of the sweep parameters and then the values of anything measured which for now can be just 1 thing (rng for this example).
Typically the data in the first and second column is unsorted which I would like to sort and then mesh with the meshgrid function, then I would like to go through all of my data set and create a 'z matrix' which is the measured values but put into the correct place to match the sorted and meshed [sx,sy] meshgrid.
%%%WHEN a=2 and b=-80 the temperature was 7
%%%WHEN a=1 and b=-90 the temperature was 84
%%%CREATE A SORTED MESH GRID OF a AND b FROM THE DATA STRUCTURE SO I CAN PLOT THEM
%%%CREATE A MATRIX OF THE CORRESPONDIG temp VALUES WHERE THE INDICES HAVE CHANGED SUCH THAT THEY CORRESPOND CORRECTLY WITH THE SORTED a AND b MESHGRID
%%%I THINK THE SORTED MESHGRID WILL LOOK LIKE:
%%%I AM HOWEVER DRAWING A BLANK AS TO HOW TO PROGRAMATICALLY CREATE THE CORRECT Z MATRIX SUCH THAT IT IS NOW:
I realise that I may not have formulated this question properly and there is a more precise way of defining the question if this is also obvious I am happy to reword my question such that any solutions are easier to find.
Also obviously I have larger data arrays and multiple instances of this and I don't preallocate my datastructure like i do here (it is read in from experimental data) but the crux is (the x-y pair is unique), (There is one 'z' value per data structure field for an unique x-y pair), (there are potentially lots of unique x-y pairs and so if this is possible without looping over each unique x-y pair and then finding the corresponding z that would be great).
Thanks in advance,