How to search for specific numbers in a structure with cell matrix

1 view (last 30 days)
As a matlab beginner I have to deal with some measure data as a celll matrix in a structure(values). The Matrix contains the different values of "Time", "Voltage" etc. I'd like to plot e.g. the voltage over the time only for a specific period, not from the beginning. I already know how to do this by calling indices, but i don't know the indices of the relevant times.

Answers (1)

Martijn
Martijn on 31 Jan 2011
Suppose you have vectors:
t = 1:10;
y = t.^2;
And you want to plot(t,y) where for example 2 < t < 5. You could use the following:
% Find the elements meeting your requirement
ind = (t > 2) & (t < 5);
% Plot only these values
plot(t(ind),y(ind))
Hint: The example above used logical indexing; this should work fine here, if for some reason you need a linear index however you can use the FIND function.
ind_lin = find(ind)

Categories

Find more on Mathematics 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!