How do I make a smaller table by filtering a larger one?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
David Stewart
le 20 Juil 2021
Commenté : Image Analyst
le 21 Juil 2021
I'm making an application that allows you to read a table from a tab delimited text file, select a row from that table, and the app displays a graph based on some data taken from that text file.
The FiberCheckTable is uploaded in a different section of the code, and the serial number (SN) is stored in column 2. The program should then show a stacked plot of the data that is stored in columns 13-16 for that specific SN. What am I doing wrong??
Here's what I have so far:
function FiberSelect(app, event)
% automatically selects serial number (SN) based on cell selected in table
indices = event.Indices;
app.SN = app.FiberCheckTable.Data{indices(1),2};
app.EvaluateCalibration(event);
end
function EvaluateCalibration(app, event)
% graph wavelength of xyz sensors in process
app.Wavelength = app.FiberCheckTable;
app.Wavelength = app.Wavelength(app.Wavelength(:,2)==app.SN,:);
app.Wavelength = sortrows(app.Wavelength,'SerialNumber','ascend');
app.WavelengthAxes = stackedplot(app.Wavelength(:,13:16));
end
0 commentaires
Réponse acceptée
Image Analyst
le 20 Juil 2021
You might need braces instead of parentheses to get the CONTENTS of the table:
% Determine which rows to extract from the table.
rowsToExtract = app.Wavelength{:,2} == app.SN; % Should be a logical vector (1/0, true/false).
% Extract only those particular rows.
app.Wavelength = app.Wavelength(rowsToExtract, :);
2 commentaires
Image Analyst
le 21 Juil 2021
There is a UI control -- a table or uitable -- that is like a widget you place on the form. That is a different beast than a variable type called a table in MATLAB. So the widget is like a listbox or button or any other widget, while a table variable is like a double, structure, cell array, etc. type of variable. So I guess you were getting confused between the table control and the table variable -- they're different things.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Specifying Target for Graphics Output 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!