Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Herbert Walter
Herbert Walter le 31 Jan 2011
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 commentaire
Walter Roberson
Walter Roberson le 31 Jan 2011
We need a small example of your data structure to give you the right command.

Connectez-vous pour commenter.

Réponses (1)

Martijn
Martijn le 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)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by