Cody

Problem 42324. Accessing value of variable whose name is stored in another variable as string.

Solution 675864

Submitted on 27 May 2015 by Alfonso Nieto-Castanon
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% n = 10; var3_correct = 10; assert(isequal(varaccess(n),var3_correct))

2   Pass
%% n = 30; var3_correct = 30; assert(isequal(varaccess(n),var3_correct))

3   Pass
%% n = 0.6; var3_correct = 0.6; assert(isequal(varaccess(n),var3_correct))

4   Pass
%% n = 500; var3_correct = 500; assert(isequal(varaccess(n),var3_correct))

5   Pass
%% n = 7.8; var3_correct = 7.8; assert(isequal(varaccess(n),var3_correct))

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!