How to extract a certain row from a struct based on a specific column name?
27 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Malte Räuchle
am 13 Aug. 2020
Kommentiert: DGM
am 27 Dez. 2024
Hello!
I want to get the row with the DisplayName 'vfzg_w' based on the name, not the number of the field!
After that I want to work with the field Data of this specific row, is that possible?
Thanks for your advice!

0 Kommentare
Akzeptierte Antwort
源樹 上林
am 13 Aug. 2020
たぶんこう
data(data.DisplayName == 'vfzg_w', :)
2 Kommentare
Maytheewat
am 27 Dez. 2024
This gives the following error
Error using ==
Too many input arguments.
Do you have any tips?
DGM
am 27 Dez. 2024
You don't have a scalar struct, so the LHS of the test is a CSL. You shouldn't be testing chars using == anyway. Use strcmp() or something.
% say i have a nonscalar struct
inpict = imread('cameraman.tif');
mask = inpict == 220;
S = regionprops(mask,'area')
% the only field is _numeric_ and _integer-valued_,
% so == makes sense here. it doesn't for char, or float.
% without the concatenation [], the LHS of this comparison
% is a comma-separated list -- i.e. multiple arguments
S2 = S([S.Area] == 2)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!