From: Ric Briney on 5 Jul 2010 10:26 Hello all I've got a problem that I've been unable to find a solution to. I'm trying to display a table in a way that is easy to read part way though a function. I have generated a table which shows the user what changes are going to be made to a simulink model, I’m then providing the user with a menu to select if they want to apply, save to csv or discard the suggested changes. Originally I was displaying the table in the console using the disp command but it tends to wrap round on to the next line and can be very difficult to actually see. I then discovered the openvar command (which opens the cell table in the array editor - like double clicking on it in the workspace does), however this only seems to work for variables in the console workspace, I worked around that by using assignin (which isn't the most elegant approach). I was also thinking that the user might even be able to edit the variable in the array editor before selecting the menu option, which would have been really good. This would be fine except the input command that follows (to provide the menu) seems to make the array editor hang before it's opened the variable, meaning that you can't see the table. I've tried inserting wait functions and using evalin but nothing seems to work. Once the function exits the table does finish opening in the editor. I know you can create a gui using guide and use uitable in the newer versions of matlab which I assume would be a better solution, however I am using R2007a which doesn't have uitable, does anyone know a good way to achieve this? Is there a command to refresh the array editor in some way that might help? Or is there a simple way to write tables to the command line without them wrapping that anyone knows of or will I need to write my own function? Below is an example that I've been working with to try and get the openvar approach to work: function test output = {'This' 'is' 'a' 'cell' 'array' 'table'}; assignin('base','CorrectionsToModel', output); openvar('CorrectionsToModel') %also tried: evalin('base','openvar(''CorrectionsToModel'')') theinput = input('Please Enter Input'); Thanks in advance for any help anyone can provide.
From: Phil Goddard on 6 Jul 2010 01:49 I'm pretty sure that uitable existed in R2007a -- it was undocumented, and with slightly different functionality to the now documented/supported version, but it was there. So the custom UI is an option. Here's a link to a file on the File Exchange that dates back to R2007a and uses uitable, which may be useful for you. http://www.mathworks.com/matlabcentral/fileexchange/16075 Phil.
From: Yair Altman on 6 Jul 2010 05:29 > I know you can create a gui using guide and use uitable in the newer versions of matlab which I assume would be a better solution, however I am using R2007a which doesn't have uitable, does anyone know a good way to achieve this? You can use the following utility to display any data in an interactive GUI table: http://www.mathworks.com/matlabcentral/fileexchange/14225-java-based-data-table >> Is there a command to refresh the array editor in some way that might help? The Array Editor (renamed Variable Editor starting R2008a) is tightly-coupled to desktop variables and refreshes automatically wen the desktop data is updated. An unfortunate side-effect of this design is that the Variable Editor needs to interact with the workspace (probably via JMI). Since there is only one Matlab computational thread, this interaction needs to wait for the user’s function to exit (the '>>' prompt returning) before being able to query the variable data for display in the Editor. The bottom line is that we cannot wait (synchronously) on the Variable Editor in our code - we can only use it from the Command Window. >> Or is there a simple way to write tables to the command line without them wrapping that anyone knows of or will I need to write my own function? You can use Urs's utility: http://www.mathworks.com/matlabcentral/fileexchange/23840-cprintf-a-pedestrian-nd-array-formatting-and-display-utility Yair Altman http://UndocumentedMatlab.com
From: Ric Briney on 9 Jul 2010 03:43 Thanks for the replies guys, I've ended up using Yair's Java table utility - which is amazing by the way. My utility now scans the simulink model finding all the blocks it needs to edit / replace and displays them using the java table utility. I've added 2 additional buttons to the table figure - Save to CSV and Apply. The user can edit the table to make sure that the blocks are being edited / replaced properly before clicking apply. The function also loads some csv file lookup tables which it uses to try and select the correct settings - these are generated by a seperate data dictionary for our system. Overall I'm very happy with it and I think this is how I will be writing future utilities that need to do similar things. So once again thanks for your help!
|
Pages: 1 Prev: textbox relocated when using exportfig Next: fitting implicit equation without local minimum |