Subscript indices must either be real positive integers or logicals???
1 view (last 30 days)
Show older comments
Hi,
Lately I'm getting this error with the following code, which was running well many times. The code stops on the second 'if', which compares the strings.
I've already checked on debugging mode if there's something wrong with the variables, but everything is ok...do you know how it could be possible? I've already restarted Matlab, but the result doesn't change. The Matlab version is R2010a.
Thank you so much!
filenames = './patch1.mat ./patch2.mat ./patch3.mat';
function Patches = ReadPatches(filenames);
if numel(filenames) > 0;
spaces = [0 findstr(filenames, ' ') length(filenames)+1];
for i = 1:length(spaces) - 1;
filename = filenames(spaces(i)+1:spaces(i+1)-1);
if filename(end-3:end) == '.msh'
[c, v] = msh2coords(filename);
elseif filename(end-3:end) == '.mat'
load(filename, 'c', 'v')
end
end
end
0 Comments
Accepted Answer
Walter Roberson
on 3 May 2013
You should be using strcmp() to compare strings, not "=="
At the command line give the command
dbstop if error
and run until the problem occurs. When it does, please show length(filename)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!