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

1 次查看(过去 30 天)
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.

回答(1 个)

Martijn
Martijn 2011-1-31
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)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by