MATLAB: How to add zero infront of number MATLAB Hi, I have to add 0 before a number let say num = 2. I want to show as num=02 Best Answer I don't think you can pad zero for a numeric number but you can do it when printing. For examplefprintf('num = %02d\n',2)Is this what you want? HTH Related SolutionsMATLAB: Adding zeros to a number A = [0 1 0 1 0];A = [A, zeros(1, 23-length(A))]; MATLAB: Remove zeros from a number Just get the edit box contents and set the 0's to nulls:editBoxContents = handles.edit1.String;editBoxContents(editBoxContents == '0') == []If you want the number, just addtheNumber = str2double(editBoxContents); Related QuestionAdding zeros to matrixAverage of termsHow to add zeros in fronts of any number in matrixWhy do I have an error on the length functionAdd number to cellIn an assignment A(I) = B, the number of elements in B and I must be the same.Add zeros to some datesHow to adjust the numbers
Best Answer