Suppose I have 3 vectors as below with the same variable name LocP generated as a result of a for loop. The number in front of the variable name LocP just represents that the variable was generated on the Nth loop.
Suppose from an independent for loop I have generated an index vector (IndexP) as below.
Is it possible to use the variable name (IndexP) to access the wanted elements of the LocP variables? Which in this case would be 3rd element from LocP(1), 1st element from LocP(2) and 2nd element from LocP(3).
I ask because my main project has two independent variables within the same for loop. One variable generates the data of interest and the other generates an index vector that gives information of the specific position of the data of interest within the first variable. Therefore the index elements differ every time the loop occurs therefore manually choosing a series of numbers is not going to help.
LocP(1) = [0.026367187500000 0.085937500000000 0.146484375000000];
LocP(2) = [0.054687500000000 0.122070312500000 0.189453125000000];
LocP(3) = [0.049804687500000 0.108398437500000 0.180664062500000];
The actual code from my real project is down below.
Data_Chan(1,:) = Data(i,:);
DataN_Chan(1,:) = DataN(i,:);
[PosP, LocP] = findpeaks(Data_Chan,Fs)
[NegP, LocN] = findpeaks(DataN_Chan,Fs);
[PeakPo(i,iNepochs), IndexP(i,iNepochs)] = max(PosP,[],2);
[PeakNe(i,iNepochs), IndexN(i,iNepochs)] = max(NegP,[],2);