4. save
Syntax
save(filename, variables, fmt);
value of fmt | file format |
---|---|
’-mat’ (default) | binary MAT-file format |
’-ascii’ | text format with 8 digits |
’-ascii’,‘tabs’ | tab-delimited text with 8 digits |
’-ascii’, ‘-double’ | text format with 16 digits |
’-ascii’,‘-double’,‘tabs’ | tab-delimited format with 16 digits |
Example: save variate var to txt-file file.txt.
save file.txt var -ascii;
save('file.txt', 'var', '-ascii');
3. dlmwrite
Write matrix to ASCII-delimited filea. Example:
dlmwrite('myFile.txt',output_var,'precision','%.2f','delimiter','\t');
2. find
Find indices and values of nonzero elements. Example:
index_postion = find(var>10, 1, 'first');
1. atan2, angle
For complex $z$, the magnitude $R$ and phase angle $\theta$ are given by \begin{align} R &= \mathrm{abs}(z) \nonumber \newline \theta &= \mathrm{angle}(z) \newline \end{align} and the statement \begin{equation} z = R \cdot \mathrm{exp}(i \cdot \theta) \end{equation} converts back to the original complex $z$.
The angle function can be expressed as \begin{equation} \mathrm{angle}(z) = \mathrm{imag} \Big( \mathrm{log}(z) \Big) = \mathrm{atan2} \Big( \mathrm{imag}(z), \mathrm{real}(z) \Big). \end{equation} Example:
z = 4 + 3i;
r = abs(z)
theta = atan2(imag(z), real(z))
theta = angle(z)
z = r*exp(1i*theta)
Output
r = 5
theta = 0.6435
theta = 0.6435
z = 4.0000 + 3.0000 i