I work in a team which shares a variety of Matlab scripts. One of my co-workers built a GUI which he named MT_v1.fig with a corresponding script MT_v1.m.
Now, I have made some edits to both the script and the figure (added a few buttons, etc).
What I want do now sounds like it should be easy: I want to rename the figure and the .m file such that I now have:
MT_v2.fig and MT_v2.m
However, when I try to do this it gives me a whole host of errors because all the callbacks in MT_v2.fig are still referencing the MT_v1.m file. I want to save the two separate version names so that people on the team can easily differentiate the two versions.
Is there an easy way to quickly update all the callbacks in MT_v2.fig so that they reference the MT_v2.m script?
I had the same issue and needed to do the following:
1- Before applying any changes to the "new" GUI/.fig and .m files, save the .fig file under the new name. The corresponding .m file will be generated.
2- Apply your changes to the .fig and/or .m files only once the new versions have been saved.
3- You can then save normally both files under the new name and everything should be fine.
That worked for me hope it does for you!
Related
Every time I simulate in Dymola, a number of "useless" (for me) files are created in the working directory - i.e. dsfinal.txt, dsin.txt, dslog.txt, dsmodel.c, dymosim.exe. I find it annoying as it messes up my directory.
Is there a way to select only the desired output files to be kept after the simulations, without the need of manually deleting the undesired ones?
Those are temporary, but necessary files for Dymola. As far as I know there is no option to delete them automatically. Of course you could script that, but I don't see a real point to it and those files are used by some functionality - e.g. dsfinal.txt is used when as simulation is continued.
Some notes: Those files are created in the working directory - which should contain temporary files only. The working directory can be set via the GUI using File -> Options -> Settings:
A rather common problem is, that there is a Open and a Load function in Dymola:
As the description states, Load does not influence the working directory, whereas Open sets it to the directory from which a file is opened. The latter is also true for opening files e.g. via a double-click from the explorer. So usually it is better to go with Load.
My advice would be to separate the directories in which models/packages are stored and the working directory. This way the working directories content can be fully deleted basically anytime...
I have a series of .m files that plots Power spectral density, one third octave band levels, spectrograms etc. Each one of them is a seperate .m file (function file to be specific) that is executed by one main .m file which opens up a GUI that interactively lets us choose what we want and then it gives us the outputs accordingly. The thing I want to do now is create a small script that will entail to initiate to run these series of .m files and store the results so that I can use these results (probably by saving them as .mat files) to plot further results.
Any suggestions or ideas are welcome! Many thanks.
Further to the above, please find below details -
so can save the myOutput (referring to Wolfie's comment) as and when the function is being called within the main .m file? The thing with the GUI is it does RUN based on user's selection to analyse .wav files. suppose i choose one file then it does the analysis according to what i want and gives me outputs. suppose i want to do the analysis for batches of .wav files at a time, then it is taking lot of time. i wish to know if i could write another script to direct this main .m file to do the analysis of required things in batches and store the results so that in the end i can use all the stored results to plot as to what i need to plot. hope this is helpful. thanks all.
You can run MATLAB scripts from command line or code with the run function.
Suppose you have an *.m file stackoverflow_playground.m with some content you can let that script run by
run('stackoverflow_playground.m')
So one master script could contain several run statements after each other to run consecutively the desired scripts given their position in the code. This master script could then also include some save routines for the obtained results.
Working on my script in Matlab, I want to rename a variable, but only the upcoming instances of it the current script.
I am familiar with Matlab rename option when pressing Shift+Enter.
But this changes all the instances of my 'new' variable in the whole script.
I want to change only the proceeding instances.
How could this be done? I also didn't find anything helpful in the Find&Replace window.
Copy the remaining portion of your code into a new .m file
Find and replace the variable you want to change.
Copy and paste it back into your original .m file.
I have renamed a .fig and associated .m file generated by MATLAB's GUIDE. Having done this, I receive a long list of error messages including the following (just a sample of them shown below):
Undefined function or variable 'my_gui'.
Error in #(hObject,eventdata)my_gui('edit34_CreateFcn',hObject,eventdata,guidata(hObject))
Undefined function or variable 'my_gui'.
Error in #(hObject,eventdata)my_gui('edit33_CreateFcn',hObject,eventdata,guidata(hObject))
Undefined function or variable 'my_gui'.
Error in #(hObject,eventdata)my_gui('edit32_CreateFcn',hObject,eventdata,guidata(hObject))
These errors all seem to relate to individual items on my GUI, such as buttons, text boxes etc.
The function and .fig file used to be called my_gui.m and my_gui.fig. However, I have sinced changed the name to my_new_gui.m and my_new_gui.fig (I've simplified the actual names for the purposes of this question).
So, the obvious solution is to go into the .m file and replace all instances of my_gui with my_new_gui. However, I've done this, and the same error message appears. I have no idea where MATLAB is the reading text my_gui from, since it doesn't exist in any of my code... Any help would be appreciated!
Edit I've discovered that these old references are written in the callbacks for each item on the GUI, which I can change by opening the Property Inspector for each individual item. However, I have a lot of items. If anyone can offer a solution to quickly edit these using a text editor, rather than clicking each individual one, I'd appreciate it!
Renaming MATLAB GUI should be done using Save As... rather than manually changing the file names. Change the file names back to the original names and change the name using Save As... option in GUIDE. This should automatically rename everything.
I want to know if there is an easy way to open a .txt file and load some comma delimited data into variables in Scratch and furthermore add some variable data from Scratch to a .txt file or similar?
I have done a fair bit of google searching but not come across anything so I thought I would ask you guys.
I would love to use Java or something but its for my school kids and I cannot teach them to do it in Java or something else as they need to do what they have to in Scratch which is annoying but something I cannot change.
Scratch does not have file IO capabilities, and i doubt it ever will.
The closest thing that i know of is importing/exporting a list. Right-click on the list watcher from the Scratch IDE, and export. It will produce a .txt file, with each list item on a new line. If you have a similarly formatting TXT file, you can import it using the same method. Each line corresponds to a list item. Comma delimited data doesn't work with this.
You can download and edit the json script for the Scratch project.
From the "See Inside" screen, File->Download to your computer.
Rename the file to have a ".zip" extension instead of just ".sb2".
Unzip the file to edit the "project.json" file.
Edit the list data under "ListName": "[your list]" as desired.
Reassemble the zip file
Remove the ".zip" extension. (Back to ".sb2")
Update the Scratch project by going to the original project and selecting File->Upload from your computer.
In this sample project I have a list called "Jobs". The project.json file has a section like this...
"listName": "Jobs",
"contents": ["Accountant",
"Actor",
"Advocate",
"Appraiser",
"Architect",
"Baker",
...
Make whatever changes you want directly to the section for your list.
Currently, Scratch has no IO abilities, as the answer above me said, But there is a mechanism called JS extenions. Currently it's a closed beta, but when it will be released everyone would be able to program Javascript extensions for scratch. That means that you will be able to create a "Open file" block yourself.