MATLAB: Left digits format if I have a number such as 1234, how can I select the left 3 digits 123? Best Answer left3 = @(x)str2double(x(1:3));left3(num2str(1234))Perhaps?Or so it doesn't error on numbers < 100left3 = @(x)str2double(x(1:min(3,length(x)))); Related SolutionsMATLAB: How to concatenate the rounded digits of a number and a string xstar=sprintf('%.2f%s',round(x,3,'significant'),star) MATLAB: Cell2mat simple manipulation question How about:x={'000','101.5'}; x2=str2double(x)or:x3 = cellfun(@str2double,x) Related QuestionHow to add one digit to another digitsIs there a format in MATLAB to display numbers such that commas are automatically inserted into the display
Best Answer