% ifitYou can also drag-n-drop data files on the program in order to directly import them into iData objects (linux and Windows versions). These are then stored in the 'this' variable (cell array), and the last one is stored as well in the 'ans' variable. When only one data file/directory is imported, it is automatically plotted.
% ifit datafile
but the following will fail:iFit >> run script.m
iFit >> for index=1:10; disp(index); end % this works
A way to be able to access the full Matlab control statement syntax (multi-line) and keep track of your work, is to start the TextEdit window:iFit >> for index=1:10
iFit >> disp(index); iFit >> end
You can type Matlab/iFit commands in there, and then use the File/Evaluate menu item to evaluate either all the content, or a selection. The result is sent into the iFit Terminal. Any variable used in the TextEdit window appears in the iFit Terminal, and vice-versa. You can open as many TextEdit windows as you wish, load/save files (e.g. .m), copy/paste filenames and raw text.>> TextEdit
iFit is a very general infrastructure, which is mostly used
through commands and scripts. However, there exist a few
dedicated Applications which provide a User Interface.
ResLibCal | Triple-Axis neutron spectrometer
simulator |
Sqw_Phonons | Phonon dispersion computations using DFT
and dynamical matrix. Read the dedicated Phonons documentation. |
miFit |
a simple yet powerful User Interface.
This one is automatically started with iFit. |
TextEdit |
an editor which allows to evaluate code |
When using the Debian installer, these Applications can be
launched directly from the 'Dash' by searching their name.
--save |
saves automatically all
files to 'ifit.mat'
(HDF format) before exiting the program (except with
Ctrl-C). You can then re-import the workspace with 'load ifit.mat' in
any further Matlab or iFit session. |
--save=FILE |
same as above, but
specify the name of the file to save to. |
--run=SCRIPT -r=SCRIPT |
reads the whole SCRIPT
and executes it. The script can contain any list of
Matlab commands, but can not include new function
definitions, except anonymous functions. New fit models
can be defined with iFunc
objetcs. |
--help -h |
Displays the help for the
iFit stand-alone program (command arguments) |
--exit |
Exits iFit when all
commands have been executed. The Ctrl-C key exits
immediately (aborts) |
-nodesktop |
Do not start the miFit
GUI (prompt only) |
data |
the data can be any valid
URL (http://,
ftp://) or filename,
or directory.
The data is imported into iData
objects, which are stored in the 'this' cell array (list). You can
then plot them with e.g. 'plot(this{:})'. |
any
single Matlab command |
Any Matlab command is
executed with the expanded 'this' list as argument. |
'"any string"' |
An argument containing a
double quote string is interpreted as a static string,
stored in 'this',
and can be passed to further commands. Be cautious
regarding the use of special characters such as ()[]{}
and even the space which may require escape backslash (
\ ). |
"'any expression'" |
An argument containing a
single quote string is evaluated as a Matlab
statement/expression. |
verbose and silent | toggle the echo of commands in the terminal. |
doc and help | open the documentation |
run <script.m> | executes a script, supporting multi-line |
propedit | open the object browser GUI |
TextEdit | open the script editor GUI, supporting multi-line |
mifit | open the workspace GUI |
d=iData('filename') | import a file |
m=iFunc('expr'); | create a model from an expression |
fits(iFunc) | list of predefined models |
fits(m,d) | fit a model to data set |
>> edit(gcf); % edit the current figure. Select the 'arrow' tool in the tool bar then double-click objects.The edit command also works with files, to launch the system text editor or a simplistic editor.
>> inspect(gcf) % open a property editor
>> 1+2
ans =
3
>> a=1+2;
>> a = [ 1 2 3 4 ]; % a vector of numbers
>> b='a string';
>> c.first=1; % a structure with two fields
>> c.second='string in a structure';
>> d={a,b,c}; % a cell array (list) containing the 3 variables a,b,c values
>> d{2}
ans =
a string
Matlab supports a set of control statements:
if condition |
if condition statements1 |
if condition1 statements1 |
for variable=vector |
while condition |
switch variable |
All Matlab statements can be written on multiple lines in
scripts and functions, or on a single line from the iFit
prompt when separating each statement with the ';' character.
We use below disp to
display a value.
>> for index=1:10; disp(index); end
>> run SCRIPT.mwhere the script can contain a full path name, and should have a .m extension.
function [out1, out2, ...] = my_function(in1, in2, ...)To call a function, simply use its name:
% comments
statements
>> my_function(1,2,3)Anonymous functions are simple functions which consist in a single statement, and return at most one value. They are defined as a variable, and called with the syntax:
>> a = my_function(1,2,3);
>> my_function = @(in1, in2, ...) statement;Matlab (and iFit) contain a very large set of functions.
>> my_function(1,2,3);
>> f = iFunc('p(1)*x + p(2)')iFunc objects can be manipulated just as numbers, and you can create more complex models by assembling simpler ones. iFunc objects support additional parameters, which in principle allow for storing any function there-in.
>> plot(f)
>> d = iData('filename');A large set of functions and operators allow to manipulate these objects just as numbers. Refer to the Methods, Load, Save, Plot, Fit and Math pages. The same remark holds for iFunc fit models.
>> plot(d)
>> fits(d, gauss)
>> saveRefer to the iData/Save page for more information on the available formats and procedures.
>> save(iData_objects, 'filename', 'format')