Extracting data from a 3D matrix
Ältere Kommentare anzeigen
Hi all,
I am struggling to find a way to extract data from a 3D matrix. what I want to achieve is -
every time the 'abs' value of column A - column B = 200 I want to extract the value in both these columns into a new array. This would then give me a new array with all the possibilities, over a defined spectrum, for calculating intermodulation distortion (at the moment this is just the 1st fundamental frequency pairs.
thanks for any help.
freq_spacing = 200;
A = [606000: 200: 614000];
B = [606000: 200: 614000];
min_value = 606;
max_value = 614;
counter = 1;
while min_value < max_value
for Aindex = (1:41)
for Bindex = (1:41)
%first order IMD
onef1 = A(Aindex);
onef2 = B(Bindex);
arr_1st(Aindex,:,Bindex) = [onef1 onef2];
end
end
min_value = min_value + .2;
counter = counter + 1;
end
arr_1st(:,3,:) = abs (arr_1st(:,1,:) - arr_1st(:,2,:));
abs (arr_1st(:,1,:) - arr_1st(:,2,:)) == freq_spacing
Antworten (1)
dpb
am 14 Apr. 2018
Try
[A,B]=meshgrid(A,B); % 2D grid of frequency points
ix=(abs(A-B)==200); % logic indexing array of locations 200 (Hz?) different
Select from your arrays for those indices (presuming, of course, the presumption I'm making that the A,B vectors are the same size as the dimensions of the actual data arrays).
2 Kommentare
Mark Healy
am 14 Apr. 2018
Where are the data associated with the differences; aren't they in arrays with fixed df grid? It should be no more than a linear relationship from the grid index above to that of that data even if not 1:1.
Or, if it's simply a base frequency and the sidebands of n*df either side like we do for bearing noise analyses where n is some integer or even fractional multiple of a fundamental frequency, it's still just a linear computation of the nearest frequency bin containing the desired...
Or, I'm totally whiffing on the need...always a possibility. :)
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!