How to call a specific element of a table
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zeynab Mousavikhamene
am 29 Aug. 2019
Bearbeitet: Andrei Bobrov
am 30 Aug. 2019
I want to
find the "radius" in which "time" is 2 and p"erhexagon" is 2.1667. There might be more than one radius that matches this criteria.
Any suggestion?
2 Kommentare
KALYAN ACHARJYA
am 29 Aug. 2019
Bearbeitet: KALYAN ACHARJYA
am 29 Aug. 2019
Still unable to resolve it, please attach the table.
madhan ravi
am 29 Aug. 2019
Learn to attach data as .mat file as shown by Andrei below, attaching a screenshot is useless!
Akzeptierte Antwort
Adam Danz
am 29 Aug. 2019
Bearbeitet: Adam Danz
am 29 Aug. 2019
Assuming your table is named "T",
% find the rows where time equals 2 and perhexagon equals exactly 2.1667
rowidx = T.time == 2 & T.perhexagon == 2.1667;
% use the row index to get the chosen radii
chosenRads = T.radius(rowidx);
Note that if you have trouble matching the floating point decimals, you may have to build in a tolerance instead of requiring an exact match. Example below.
% Define tolerance
tol = 0.001; %accepted if perhexagon value is +/-tol from target
% find the rows where time equals 2 and perhexagon equals exactly 2.1667
rowidx = T.time == 2 & abs(T.perhexagon - 2.1667)<tol;
2 Kommentare
Zeynab Mousavikhamene
am 29 Aug. 2019
Bearbeitet: Zeynab Mousavikhamene
am 29 Aug. 2019
Adam Danz
am 29 Aug. 2019
This is where my "note" comes in at the end of my answer. Your "perhexagon" values aren't really 2.1667. Those are just the first 4 decimal places. So you need to build in a tolerance. For example, accept any rows where perhexagon is within 0.0001 within the target value. I'll update my answer.
Weitere Antworten (1)
Andrei Bobrov
am 29 Aug. 2019
Bearbeitet: Andrei Bobrov
am 29 Aug. 2019
load data.mat
lo = ismembertol(T{:,{'time','perhexagon'}},[2,2.1667],'ByRows',true,...
'DataScale',[1 .00001]);
out_radius = T.radius(lo);
2 Kommentare
Andrei Bobrov
am 30 Aug. 2019
Bearbeitet: Andrei Bobrov
am 30 Aug. 2019
You do not know how to download, sorry.
Exsample my laptop with Ubuntu (I from Russia :) ):
>> load '/home/andrei/Загрузки/data.mat'
>> lo = ismembertol(T{:,{'time','perhexagon'}},...
[2,2.1667],'ByRows',true,'DataScale',[1 .00001]);
out_radius = T.radius(lo)
out_radius =
1
2
>>
Siehe auch
Kategorien
Mehr zu Tables 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!