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

5 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Eugene
Eugene am 30 Mai 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 :)).

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by