Need help with 'Undefined function or method 'minus' for input arguments of type 'cell'

5 ビュー (過去 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

採用された回答

Eugene
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 ExchangeData Types についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by