How do i retrieve data from a vector of idexes?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Reachnext is a vector that contains the indexes of certain files i want. These files are within the larger file MCR_full.MIB037.Reaches. How do i retrieve the actual files within reachnext and not just their index?
I tried writing the following
temp = (MCR_full.MIB037.Reaches.(reachnext(i,k).kin));
but got this error
Index in position 1 exceeds array bounds. Index must not exceed 1.
any help would be great!
thank you!
1 Commento
James Tursa
il 26 Gen 2022
You need to give us more information. What exactly are the data types and sizes of all of the variables, including the fields, that you are working with?
Risposte (1)
Walter Roberson
il 26 Gen 2022
Reachnext is a vector that contains the indexes of certain files i want
Then Reachnext contains numeric values? But your code uses reachnext(i,k).kin which would require that reachnext(i,k) evaluates to either a struct or an object
Your code would be consistent with the possibility that reachnext is a struct array and that reachnext(i,j) is a scalar struct that has a field named kin that contains a character vector, and that the contents of that character vector identify a field to use within the scalar struct MCR_full.MIB037.Reaches .
If that were the case then the error would just be that the nonscalar struct reachnext only has one row
2 Commenti
Walter Roberson
il 27 Gen 2022
t = kins(:, 1); %first column is time
y = kins(:, 3); %third column is 'up'. switch to '2' for 'out'.
Is kins a string() array that contains "up" or "2" or "out" in the third column, and a string-represented time in the first column? I am concerned because in context, your y would have to be a cell array of character vectors, or a categorical array, or a string array, in order to be able to hold the 'up' representation. Of those, categorical is the only one that you might hope to be able to findpeaks() on.
for i = 1:length(reachlimit)
index = reachLimit(i);
prominencePeaks(k,i) = peaks(index);
end
You could vectorize part of that:
high_peaks = peaks(reachlimit);
prominencePeaks(k,1:length(high_peaks)) = high_peaks;
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!