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 CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by