1

I'm trying to use num2str in a load function as follows

route=3;
samples=1;
pct=100;

path('C:\')
load(['B2A_Sample_r',num2str(route),'_',num2str(pct),'%_',num2str(1000+samples)])

I also tried:

filename=char(['B2A_Sample_r',num2str(route),'_',num2str(pct),'%_',num2str(1000+samples)]);
load(filename,'-mat')

I'm having to shut down and reboot matlab every time I get this error.

1 Answer 1

5

You are clearing your path each time you run, so MATLAB can't find any files or functions, whether built-in or not (including num2str). Each time it tries, it only looks in C:\ and then gives up. Try this:

route=3;
samples=1;
pct=100;
filename=char(['B2A_Sample_r',num2str(route),'_',num2str(pct),'%_',num2str(1000+samples)]);
directory = 'C:\';

fullfilename = fullfile(directory,filename);

load(fullfilename);
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.