Extract rows from 2 different matrices with different dimensions using If statement
Show older comments
Hi guys. Hoping that you're all ok.
For my project i need to every equal runID (column 5 on both matrices) to extract the rows that contains the higher value of the energy (column 3 on both matrices) in the same eventID (column 2 on both matrices).
Example, for a runID == 0, e need to extract the higher value of the energy on both matrices in the same eventID == 6. Using the .txt files i've attached, that corresponds to the first row in both matrices.
This is my current code:
for i=[1:99]
file_number=sprintf('%d',i);
R = fileread(strcat('right',num2str(file_number),'.txt'));
R(R == '*') = '';
AR = cell2mat( textscan(R, '%f %f %f %f %f %f', 'headerlines', 4));
L = fileread(strcat('left',num2str(file_number),'.txt'));
L(L == '*') = '';
AL = cell2mat( textscan(L, '%f %f %f %f %f %f', 'headerlines',4));
for n=[0:max(AR(:,5))];
if AR(:,5)==n;
if AL(:,5)==n;
idx=find(AR(:,2)==AL(:,2))
end
end
end
end
I've already tried different ways to exctrat what i need but i found always a different problem every time.
Thanks in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Downloads in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!