mgc77
mgc77

Reputation: 113

Undefined function 'num2str' for input arguments of type 'double'

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.

Upvotes: 1

Views: 1386

Answers (1)

craigim
craigim

Reputation: 3914

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);

Upvotes: 5

Related Questions