Need help with 'Undefined function or method 'minus' for input arguments of type 'cell'
3 views (last 30 days)
Show older comments
I can't understand why I keep getting this error. A similar script does not experience this. Below is the snippet of code causing the error. scan_acquisition_time is of char type. ScanValue is of double type.
Please can someone help?
scan_acquisition_time = cellstr(num2str(MLTdata(2:end,3)/(1000*60),4)); % Convert to minutes
lowestDifference = 9999999;
lowestPos = 0;
for i = 1:length(scan_acquisition_time)
currentDifference = abs(scan_acquisition_time(i) - ScanValue);
if currentDifference == 0
nearestRT = i;
break;
else
if currentDifference < lowestDifference
lowestDifference = currentDifference;
lowestPos = i;
end
% Check to see if this is the lowest
nearestRT = lowestPos;
end
end
0 Comments
Accepted Answer
Eugene
on 30 May 2013
scan_acquisition_time
Is a cell array of strings so you cannot do this
abs(scan_acquisition_time(i) - ScanValue)
in your code. Not sure why its converted to a string but you should have:
scan_acquisition_time = MLTdata(2:end,3)/(1000*60);
Then it should work (assuming the rest of the code is OK :)).
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!