MATLAB GUI set default values - matlab

I am working on a GUIDE in Matlab and I have to constantly change a couple of Edit Text values.
I have realized that if I change the String value of an Edit Text from the property inspector in the .fig file it sticks there when I run the code even if I close Matlab and reopen it, so I suppose that it is stored somewhere. I would like to know if there is a way of changing those 'default' values while running the gui.
I want to add a pushbutton to set the displayed data as default, so it is kept for the next time I run the code.
Thanks very much in advance!

Not sure if there is a more elegant way, but you can do the following as a workaround:
Once the button is clicked
Create a file
Write new default values instead of older ones
At the start of GUI
Open the file
Get the default values
Set the default values on GUI

Related

VSCode keeps removing the last line of 2 empty lines at the EOF

I'm using a managed VSCode environment (so some settings have been pre-configured for me) and it keeps modifying the empty lines at the end of the file every time I try to save it.
My Dockerfile is auto-generated and has 2 empty lines at the end of the file. However, when I save any modification to the file, it removes one of the empty lines automatically. When I add it back and save it, it still removes it. What is the setting I need to disable to get ride of this behavior?
I was looking at this setting but not sure that this fixes it:
Bottom-left corner
Settings:
Text Editor -> Files:
Scroll until you find this setting and uncheck it:

LibreOffice Calc: Formula does not recalculate

I created a new spreadsheet with LibreOffice 6.4 and noticed that formulas do not execute (and recalculate). So, when I write =1+1 or =A1+A2 (with values in those cells), nothing happens. Likewise, when I copy and paste formulas from older spreadsheets, nothing happens either.
I have found some advice in various forums that point to Tools->Options and LibreOffice->Preferences (since I have a Mac). One source tells me that auto-recalculation is disabled for reasons of backward compatibility with Excel (what I do not understand as I just created a new file).
I have enabled 'Always recalculate' for both options in LibreOffice->Preferences (Option LibreCalc->Formula):
Nothing in the 'Calculate' Option tab seems to indicate anything in this direction.
This seems not to change anything. What am I missing?
How can I make sure that everything always recalculates and always executes all my formulas?
Thanks!
Try this:
Select your range ; hit CTRL+H ; Found = ^. ; Replace = & ; check "regular expressions" box below ; "replace all" button;
It works better if you create a new empty spreadsheet and then paste your data.
What worked today under Windows only: Re-create the formula in a new column. After it works correctly, Copy or Move the new cell into the old position, overwriting everything in the cell that was not calculating.

Matlab GUIDE Display Current Date in Edit Text box

I am making my very first GUI using GUIDE and I am running into a problem with one of my Edit Text boxes. The Edit Text box will require the user to enter a date using the mm/dd/yyyy format. I expect that the user will be entering the current date 99% of the time, so I would like to have the current date (in mm/dd/yyyy format) already entered in the text box for the user.
I was able to achieve something like this in Matlab's Command Window using
datestr(date, 'mm/dd/yyyy')
However, I am unsure where/how to implement this code into my GUI to get it to display the date. Any help would be greatly appreciated. Thanks!
If edit1 is the tag to the editbox, add this to OpeningFcn for the GUI -
set(handles.edit1,'String',cellstr(datestr(date, 'mm/dd/yyyy')));
Thus, today's date would show up in the editbox, once the GUI loads up.
If I understood your question right, you need to use the "String" property of your edit box with the output from datestr(date, 'mm/dd/yyyy').
For instance:
set(handles.EditBox,'String',datestr(date, 'mm/dd/yyyy'));
and that should do it. You can put this line in the Create Function of the edit box, so that when the user will open the GUI the text will already be there.
Hope that's what you meant!

Dynamically updating text in Matlab GUI

I think it should be pretty simple what I want to do, basically I have one edit box that displays a value in percentages and another that I want to update to display raw values. I've tried using the following code under the edit1 (percent) callback:
currentKey = str2num(get(gcf,'CurrentKey'));
percent = str2num(get(handles.edit1,'String'));
if ~isnan(currentKey) && ~isnan(percent) && 0<=percent && percent<=100
set(handles.edit2,'String',num2str(2*percent))
end
But it will only update the second edit box if I first click outside of the first one. Anyone have an idea of what I should be doing?
Thanks!
I think this link should help you:
How can I make the text that I enter into an edit text box update dynamically?
Solution:
This enhancement has been incorporated in Release 2011a (R2011a). For previous product releases, read below for any possible workarounds:
This is expected behavior of the Edit Box UICONTROL in MATLAB.
You can try using the 'keypressfcn' to grab the keyboard input. The attached two files demonstrate the ability of real-time text update. As you enter text into the upper edit box, the text will be copied to the edit box beneath it as you enter.
Please download the following two files:
test_keypressfcn.m
test_keypressfcn.fig
Execute the program.
A GUI will appear. Enter text in the upper edit box displayed in the GUI.
Observe the text in the lower editbox is updated dynamically or in real-time as you enter test in the upper edit box.
Please note that this will work only for text that is continuously entered in the editbox. If you type in between words already entered in the editbox the gui will not perform as expected. You will need to implement logic similar to the one in this example to get the behavior that you desire.

rename ui file in matlab

I am working on a gui with guide in matlab. Inbetween I devided to name the file
different and renamed it. I also renamed all functions to the new filename in the .m file
and all objects in he .fig file.
However when I start the application I still see this error
??? Undefined function or method 'uiSchwingungen' for input arguments of type 'char'.
Error in ==>
#(hObject,eventdata)uiSchwingungen('edit1_CreateFcn',hObject,eventdata,guidata(hObject))
Where uiSchwingungen is the old not existing filename.
Where is this code section hidden (It is not in the .m file, and the .fig is binary)
You need to open the .fig in GUIDE, right click on an element (like a button), go into property browser, look for the CallBack property, click on its field to edit it, and you will find the text saying
#(hObject,eventdata)uiSchwingungen('edit1_CreateFcn',hObject,eventdata,guidata(hObject))
You will need to replace uiSchwingungen with the name name of that element (which will be in the Tag field of the Property Inspector).
Go through all the buttons, text boxes, etc., as this mistake probably will have occurred more than once.