How to display formatted numbers from a cell array with n decimal places
问题 I have a cell array that contains both numbers and strings. I want to print the cell array so that I will see only 5 numbers after the decimal point. For example: c{1, 1} = pi; c{2, 1} = pi / 2; c{3, 1} = pi / 4; c{4, 1} = 2 ^ 0.5; After using format long this is what I receive: >> c c = [3.141592653589793] [1.570796326794897] [0.785398163397448] [1.414213562373095] But I want that the output will be: >> c c = [3.14159] [1.57079] [0.78539] [1.41421] 回答1: A possible solution is to generate a