Incorrect Logical Condition Statement
Show older comments
Hi,
I have a variable (let's call it 'data') and dependent on whether the user is left ('L) or right ('R') footed I wish for the respective data to be called.
I.e. for if 'L' then I want ('data') to be: 'data_l'
If 'R' is selected then I want ('data') to be: 'data_r'
Essentially I wish to add in the respective 'l' or 'r' to the end of the name in accordance to whether the person is left or right sided.
Leg = 'L'; %change between L and R
if Leg == 'L' ;
LEG = 'l';
else Leg == 'R';
LEG = 'r';
end
Tables.knee_flex_LEG % would like LEG to change to 'l' or 'r' accordingly
Unrecognized table variable name 'knee_flex_LEG'.
I believe the if function is the one I need to use. However I am unsure how to add the option into the script
1 Comment
KSSV
on 16 Jun 2020
Don't use
if Leg == 'L'
use
if strcmp(Leg,'L')
Accepted Answer
More Answers (1)
Leg = 'L'; %change between L and R
vnm = sprintf('knee_flex_%s',lower(Leg));
Tables.(vnm)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!