Need help with 'Undefined function or method 'minus' for input arguments of type 'cell'
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Eugene
2013-5-30
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 :)).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!