To give a simple example. Having a variable or function misspelled, the LS gives a suggestion "Cannot find name 'voteings'. Did you mean 'votings'?
Is there a way to quickly accept those suggestion?
Related
In this question, I asked how I can add a custom package to the MODELICAPATH on startup, but there was some ambiguity in the answers. Based on the answers, I can use either
openModel("path\to\file.mo")
or
openModelFile("Fully.Qualified.Model.Name")
I would like to know how these commands differ, if at all, and when to use one or the other.
EDIT: if you answer please provide sources in the Modelica documentation. I am not sure how to even navigate the documentation to find these commands so this is probably a big handicap.
Chad,
For any questions related to the "built-in" commands in Dymola, please be aware that you can get some basic documentation by using the document(...) function (apparently, help was too pedestrian and elucidate was too pretentious?). This command can be invoked from the command line on the bottom of the "Simulation" tab in Dymola. It takes a string of the function name as the argument. So, to answer your question:
document("openModel");
function openModel "open a Modelica-file"
input String path "File-path to open";
input Boolean mustRead := true "If false we can skip reading the file";
output Boolean result "true if successful";
"Opens a Modelica-file and pops up a window with the model in it"
end openModel;
document("openModelFile");
function openModelFile "open a Modelica-model from a file"
input String model "Model to open";
input String path := "" "File-path to open (can be the empty string)";
input String version := "" "Version to open (can be the empty string)";
output Boolean result "true if successful";
"Opens a Modelica-file and pops up a window with the given model in it"
end openModelFile;
Sadly, I don't think the documentation quite captures the difference here. In fact, I would argue the names are really backward if you think about it. openModel takes a file as an argument and opens the definition contained in that file (typically a package but not necessarily). On the other hand, openModelFile takes a model name as an argument and opens that model in the model browser (searching the MODELICAPATH, if necessary, to find and open the model).
I hope that helps.
I am relatively new at Matlab.
I am trying to create an alias for a command that looks like the following.
run('full/path/to/some/script').
In particular, I would like to be able to write something equivalent to Bash's
alias myAlias = run('full/path/to/some/script')
And then be able to type myAlias and get the same effect as the right hand side.
I have looked at the documentation here, but I still get the error Undefined function or variable 'alias' when I try to use it, even after I first type syms at the prompt, so I believe that either I am not importing the toolbox correctly or this is not a feature in R2011b.
One additional requirement is that I would like the alias to stick even after I call clear, which should clear all the other active variables in the workspace.
for example:
f = #() run('foldername\scriptname')
then just writing f() will execute scriptname.
Here I've used an anonymous function, you can add more content to it if needed.
You can make #natan's answer tolerate clearing the workspace by making it an m-file.
In myAlias.m, put run('full/path/to/some/script'). I'm sure you are aware of this solution, but you might not want to do so, because of the resulting messy file system.
You can simply add the m-file to some folder and use addpath('where/ever/you/put/the/script') to make it accessible.
Is there a way for "ipython3 notebook" to receive command line arguments with its 'run' button?
Thank you very much.
I just encountered this problem when I tried to run some scripts using argparse library in Jupyter Notebook. Since I don't want to do much modification to the code, I needed to provide sys.argv[] to the parser.
In my case, such code can solve the problem:
import sys
sys.argv=['self.py','arg1','arg2']
Because in a real command line, the first element of sys.argv is the name of the script, so you have to provide a random script name or a name that suitable for your application, and the following arguments are just like they are passed by a real command line.
This works for me so far, but I don't know if it is safe and elegant, wish this could help you.
Do you mean the Cell -> Run menu item? If so, no. The notebook's not really designed to be used like that. What are you trying to do?
Does anyone know why one can't use the command
combnk(1:3,2)
in Matlab 2011a, or is there any way to make this built-in function working? The error message I got is
???Undefined function or method 'combnk' for input arguments of type 'double'.
The two most common reasons for Undefined function or method-errors are (1) typos, and (2) lack of the appropriate toolbox.
If you're sure you didn't make any spelling mistake, try ver on the command line to check which toolboxes you have installed. If the statistics toolbox is missing, there won't be combnk on the path.
additional tip by Colin T Bowers
If ver indicates you do have the statistics toolbox, then try which combnk. If this returns combnk not found, then you may need to refresh your path, with something like restoredefaultpath then savepath
I can use process-name to get the name of the process, but can I change the name after starting it? I looked in the manual, and even in the source and haven't found anything that seems like it would do this.
There's only one line in Emacs' process.c source file where p->name is set for a process p, and that is in the function make_process. All other functions just read that value, they never (re-)set it. So it seems the answer to your question is "no".
You could, of course, try to implement your own function that changes the name of a process. See here
for more information.