indexing with cells (need specific value in all the rows of a column
44 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have data populating in a cell as such:
I'm trying to extract data from all of the rows in column 6. When I try:
tx_data{:,6}(3,:)
but I get:
Expected one output from a curly brace or dot indexing expression, but there were 5
results.
I'm trying to plot those 5 results for a graph that will be updated per measurement. Obviously it sees the 5 results that I'm looking for, but I can't seem to actually get that data to pass to my function (something like what's below...TBD):
plot(gui_app.TRPApp.UIAxes, tx_data{:,6}(3,:));
The number of rows in this cell array will be dependent on the test being run. I may need to do something similar while separating data marked at 'v' or 'h', but I'm not quite sure if I'll need that or not.
Any help would be much appreciated!
0 commentaires
Réponses (1)
Gaurav Garg
le 28 Déc 2020
Modifié(e) : Gaurav Garg
le 28 Déc 2020
Hi Scott,
While using tx_data{:,6}(3,:), you were expected to get an error. That's because intermediate brace {} indexing produced a comma-separated list, and to perform indexing, it must have produced a single value.
However, there is one other thing you can do -
% Assuming that c is a cell array of size (4,4)
c{1,2} = [2,2,2,2]
c{2,2} = [2,2,2,2]
c{3,2} = [2,2,2,2]
c{4,2} = [2,2,2,2]
[c{[1:4],2}] % This command helps you convert the second column in the cell array to a single-dimensional array.
plot([1:16],[c{[1:4],2}]) % You can use it as a normal 1-D array and plot the values
In your case specifically, you can manipulate this 1-D array to plot only the required values. (tx_data{:,6}(3,:))
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!