Cody

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

Solution 673462

Submitted on 21 May 2015 by goc3
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))

n = 10

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

n = 30

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

n = 0.6000

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

n = 500

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

n = 7.8000

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!