Effacer les filtres
Effacer les filtres

Trying to Increase efficiency by avoiding using If statements to select data

1 vue (au cours des 30 derniers jours)
Alonso Figueroa
Alonso Figueroa le 26 Jan 2023
Hello,
I have a wro sets of data (big structures) named 'L_Data' and 'R_Data' and I am trying to select R or L acoording to a list of subject injury side.
I am trying to avoid using If statements to increase efficiency as much as possible as this is a large set of data.
Is there a way to access 'L_Data' and 'R_Data' by creating:
L_Data = struct(Subject1,Subject2)
R_Data = struct(Subject1,Subject2)
SubjectSide = 'L'
VarName = [SubjectSide,'_Data']
Output = mean( (VarName).Subject1 , 2)
Thank you.
-Alonso

Réponses (1)

Steven Lord
Steven Lord le 26 Jan 2023
Can you dynamically create and access variables with numbered names like x1, x2, x3, etc. or similar names like L_Data and R_Data? Yes.
Should you do this? The general consensus is no. That Answers post explains why this is generally discouraged and offers several alternative approaches.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by