How to call a certain part of a matrix which is a value of a field of a structure?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rightia Rollmann
am 7 Feb. 2017
Beantwortet: Guillaume
am 7 Feb. 2017
What I want to do is to access the first column and then the second column of a 5-by-7 matrix which is the value of a field named B. B is the third field of struct A. How can I do it dynamically best?
0 Kommentare
Akzeptierte Antwort
Guillaume
am 7 Feb. 2017
Your description is really not clear. An example would help.
Get 2nd and 3rd column of matrix stored in field 'B' of structure A, regardless of the order of fields:
A.B(:, [2 3])
Get 2nd and 3rd column of matrix stored in the 3rd field of structure A, regardless of the names of the fields
fn = fieldnames(A);
A.(fn{3})(:, [2 3])
0 Kommentare
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!