I Need to understand a very Long matlab file.
It is very tedious to put Breakpoints everywhere.
I wondered if there is an Option to track every possible variable at once ?
Something that would maybe store each variale in a text sheet and diaplays how they Change througout the code...
There are many many variables.
What I want to do is to create a scribt, where I can Input a list of variable names. The script then tracks those variable names within the program and exports them every time they Change.
Input: List of variables and programm Name (other script)
Content: Tracks variable in the Programm
Output: Table with tracked variables
Name_variable_1 |Value at line...|Value at line...|Value at line...
Name_variable_2 |Value at line...|Value at line...|Value at line...
.
.
.
Thanks.
You could maybe save the workspace periodically and then make a seperate MATLAB script that graphs the changes of the variables or writes out a text file for it?
I assume you're familiar with MATLAB, but just to be safe:
http://de.mathworks.com/help/matlab/ref/save.html
Just append the variable's contents to a text file or save the entire workspace and parse it later.
Related
I have a master .slx where I have hundreds of models inside and I want to know if some variables are used or not.
I have used grep and findstr in the directory where my whole project is but that is only showing me the files where the variable is declared (.m file) but not where the actual variable is used in the model.
I have tried opening the .slx and do a ctrl+f and yeah, it is telling me where the variable is used but this is not convenient since I have around 100 variables that I need to search for.
Is there a systematically way to do the search throughout the models?
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 want at the end of my program to get the values stored at certain variables and append them to a file let's say "result". I am going to run it several times (for different parameters) at night and then check results in the morning.
Basically, I am looking for something similar to redirection in linux (>>) for matlab.
I am using the diary function to store the whole messages from my program and i want to keep those for verifying later.
But here what I want is just some specific values. So how to do it?
It does not necessary have to be in the same file. If I can get each result in a separate file, that is ok too.
You can use a combination of diary and any function which can append data to a text file, but you have to turn off diary before writing. A short example using save
f='example.txt'
diary(f);
for ix=1:10
disp(ix);
diary off %diary off to flush
save(f,'ix','-append','-ascii')
diary(f);
end
Instead of save you can also use fprntf or dlmwrite
I need to create a matlab mfile that will run another matlab file with default values given in a txt file. It's ment to be useful for testing programs, so that user may specify values in a txt files and instead of inputing values every time he starts the program, my script will give the program default values and user will only see the result.
My idea is to load tested file into a variable, change 'variable=input('...');' for variable = default_variable;, save it to tmp file, execute, and than delete tmp file. Is this going to do the job?
I have only two problems:
1) How to eliminate the problem of duplicated variable names - i mean this must work for all scripts, i don't know the names of variables used in tested script.
2) As I wrote before - is this going to work fine? Or maybe I missed a easier way to do it - for example maybe I don't have to create a tmp file?
I really need your help!
Thanks in advance!
If the person who has to edit the default values has access to Matlab, I would recommend saveing the values in a mat file and loading them when needed. Otherwise you could just write a smalls cript that contains the assignment to certain variables, but make sure to keep this small. For example:
maxRuns = 100;
clusters = 12;
So much for setting up the defaults. Regarding the process my main advice is to wrap the thing that you want to test into a function. This way variables used in the code to call the 'script' will not interfere as a function gets its own separate workspace. Check doc function if you are not familiar with them.
Is it possible to save the variables or just a hash in perl workspace? For example, this can be done in Matlab with 'save' function.
edit: I am reading several text files and generating a hash out of them. When a new text file comes, I want to update this hash w/o re-doing everything from the beginning.
Thanks.
You can use eg. the Storeble module or YAML or JSON to save the hash between sessions.