0

A text file could be loaded as below:

load sourceETA/Record1/result1.txt

How can I use a variable in address of loading? For example (n is a variable):

[load 'sourceETA/Record1/result',num2str(n),'.txt']

But the above code doesn't work! How do I do?

2
  • 2
    If you would have just typed help load into Matlab you'd have your answer. Commented Jun 15, 2015 at 22:09
  • That wasn't help me! Commented Jun 15, 2015 at 23:20

1 Answer 1

1

The documentation: http://www.mathworks.com/help/matlab/ref/load.html, shows that you can supply a string to load by doing:

load(filename)

where filename is a string. In your case, you can do:

load(['sourceETA/Record1/result',num2str(n),'.txt'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.