Info
This question is closed. Reopen it to edit or answer.
How to change valuo of variable with for loop ?
1 view (last 30 days)
Show older comments
I want to change my variable value. I have 204 value in my output variable. I want to change it to specified. if the value is 1, change to 'One'. if the value is 2, change to 'Two'. I try my code but the variable name wont looping. Please help me.
m = matfile('elm_output.mat');
output = m.output;
required = output(1:204);
for i = 1:length(required)
if required(i) == 1
lbl = 'One';
name = {lbl};
end
if required(i) == 2
lbl = 'Two';
name = {lbl};
end
end
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!