Cody

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

Solution 1995019

Submitted on 29 Oct 2019 by Nikolaos Nikolaou
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))

var3 = 10

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

var3 = 30

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

var3 = 0.6000

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

var3 = 500

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

var3 = 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!