Finding indices of certain numbers from simulation data
5 views (last 30 days)
I want to find out the index values of certain numbers from an array dataset obtained from a Simulink simulation. The simulation results are stored in the workspace as an array. I am logging it to the workspace using a scope.
I tried using the find() command to find the index values, but it just returned an empty vector. I even tried using ismember() to return 0 or 1 based on whether a number belongs to that simulation data, but that also returned an empty vector.
The find() command works fine when using it on arrays imported from excel sheet.
I am not sure what I am doing wrong. Any suggestions or advice would be of great help. Thank you very much in advance.
Edit: I have attached the simulation file
Sarvesh Kale on 6 Mar 2023
Hi Abhinav Aravind,
Suppose your logged data is x in workspace then to find index of a certain number in that you can do the following
n=1:length(x) % generate index vector
key = 2 ;
idx = x == key % comparision to search your number
n(idx) % this will give you index
I hope this helps