Pregunta

I have a table where I imported data using javaaddpath. I would like to limit the significant figures of this java database in Matlab.

I use javaaddpath to add the string I would like to work in and from there I select a database. Once in the database I fill a listbox with messages from the java database. From there I generate a template and check off the ones I would like to work with and hit a plot button. This populates a table with data (again, from the database in java). I would like to know how to limit the significant figures of the numbers that fill up that table.

format short

and

fprintf

aren't really relevant to me here because I'm trying to put the output into a table, which stores as a cell array. I'm currently working on trying the function

vpa(A,d)

but it doesn't accept a cell array or a matrix. I am willing to populate the table as normal, extract the data, format it, and then repopulate the table, I'm just unsure how to do so.

Any help or websites to point me to would be very much appreciated. I also posted this query on the Mathworks help forum (here), but haven't had any luck.

¿Fue útil?

Solución

You can set the ColumnFormat property of the uitable to be any string that the format command accepts. For example, if your table has one column you can set the property to {'short g'} (it has to be a cell array, one value per column).

Note that although the format command accepts shortg, in some releases of MATLAB the ColumnFormat property only accepts short g with a space (I think this is a bug).

If you need a number of significant figure that is not provided by one of the options to the format command, the best solution I've found is to set all the column formats to char, and convert numerical contents to strings myself using the more flexible capabilities of sprintf.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top