octave

Hide octave-workspace file from home directory

对着背影说爱祢 提交于 2019-12-02 01:03:32
I would like to change the file octave-workspace from my home directory, simply renaming it to .octave_workspace . How can I manage to make octave recognize a workspace file (or create a new one) with this new name? Thanks. That is the purpose of the octave_core_file_name() function. Add the following to your .octaverc file: octave_core_file_name (".octave-workspace") OSX Solution: You can use chflags To hide a file from Finder: chflags hidden /Path/To/File To unhide: chflags nohidden /Path/To/File Linux Solution: From what I'm reading here, you can create a "hidden" files file, which contains

What is the point of the deal() function in Octave / MATLAB?

十年热恋 提交于 2019-12-02 01:01:57
问题 Some reference code uses the function deal() trivially, like [a, b, c] = deal (1,2,3) As described in the documentation (for Octave and for MATLAB), the function simply copies the inputs to the outputs. Why use deal() in this case, or even in general? I'm trying to learn "more correct" MATLAB/Octave usage, and wondering if I'm missing something significant. Perhaps, is this usage... conventionally stylistic or idiomatic, in place of simple assignment like a=1, b=2, c=3 or the more arcane list

How to automatically create variables which are column extracts from a matrix

杀马特。学长 韩版系。学妹 提交于 2019-12-02 00:50:30
问题 I have an n*n matrix and I want to extract every 3 columns and keep the result in different variables. I know that it is possible to do it in this way: A1 = A(:,1:3); A2 = A(:,4:6); A3 = A(:,7:9); But I would like to simplify and automate this for managing a large amount of data! A = [1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54

How to vectorize row-wise diagonalization of a matrix

痞子三分冷 提交于 2019-12-02 00:50:14
I have an n-by-m matrix that I want to convert to a mn-by-m matrix, with each m-by-m block of the result containing the diagonal of each row. For example, if the input is: [1 2; 3 4; 5 6] the output should be: [1 0; 0 2; 3 0; 0 4; 5 0; 0 6] Of course, I don't want to assemble the matrix step by step myself with a for loop. Is there a vectorized and simple way to achieve this? For a vectorized way to do this, create the linear indices of the diagonal elements into the resulting matrix, and assign directly. %# create some input data inArray = [10 11;12 13;14 15]; %# make the index array [nr,nc]

Load a text file containing both numbers and letters

帅比萌擦擦* 提交于 2019-12-01 23:45:44
I have a text file that looks like so: A B C 1 2 3 (This is just a minimal example of what I actually have. My actual files are HUGE and vary in number of rows.) I would like to load in this file into Octave. However, the file contains letters, rather than just numbers. When I'm trying to apply the load function, I get errors, and I guess this is because the load function only accepts numbers. What function should I use instead? Call fopen, fscanf, and fclose. The format string must be different for lines containing only letters (like '%s\t%s\t%s' ), and for those which contain only numbers

How to multiply two rows or columns?

五迷三道 提交于 2019-12-01 22:19:31
a = [1, 2, 3]; b = [3, 2, 1]; c = a * b; yields error: operator *: nonconformant arguments (op1 is 1x3, op2 is 1x3) Why can I not multiply these two rows of the same size? I shouldn't have to run a for loop for this, but I don't know of another way... I saw section 1.2.3 here , which indicates (to me at least) that I should be able to do it . You made 2 rows, which can't be multiplied together. The general form of matrix multiplication is " Row-Dot-Column ", which means take the dot product of each row with each column. In your case you have 1 row, but 3 columns (which doesn't work!). a = [1,

Implementing 'curly' and 'access' “chaining” functions in matlab

a 夏天 提交于 2019-12-01 22:00:50
问题 I read this article on the mathworks blog about functional programming in matlab, and two of the helper functions there were: paren = @(x, varargin) x(varargin{:}); curly = @(x, varargin) x{varargin{:}}; The obvious third one to complete the trio (and in keeping with the five-letter theme) would be: acces = @(x, field) x.(field); Putting the discussion of whether it's a good idea to implement chaining in this manner or not in matlab aside (note: octave supports chaining by default), paren

How to automatically create variables which are column extracts from a matrix

夙愿已清 提交于 2019-12-01 21:49:19
I have an n*n matrix and I want to extract every 3 columns and keep the result in different variables. I know that it is possible to do it in this way: A1 = A(:,1:3); A2 = A(:,4:6); A3 = A(:,7:9); But I would like to simplify and automate this for managing a large amount of data! A = [1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81] Expected result: A1 = [1 2 3 2 4 6 3 6 9 4 8 12 5 10 15 6 12 18 7 14 21 8 16 24 9 18 27] A2 =

What is the point of the deal() function in Octave / MATLAB?

丶灬走出姿态 提交于 2019-12-01 21:34:47
Some reference code uses the function deal() trivially, like [a, b, c] = deal (1,2,3) As described in the documentation ( for Octave and for MATLAB ), the function simply copies the inputs to the outputs. Why use deal() in this case, or even in general? I'm trying to learn "more correct" MATLAB/Octave usage, and wondering if I'm missing something significant. Perhaps, is this usage... conventionally stylistic or idiomatic, in place of simple assignment like a=1, b=2, c=3 or the more arcane list-unpacking of cell-arrays like [a,b,c] = {1,2,3}{:} , but even more restricted than Python argument

Generate matrix of bits

为君一笑 提交于 2019-12-01 21:16:20
I would like to take an integer n defining the number of bits in my communication code and a vector defining the alphabet I am assigning to bits 0:n-1 , and output a matrix/cell array containing the alphabetic notation for each state, i.e.: function M = mycommarray(3,[-1,1]) produces M = [{-1,-1,-1}, {-1,-1,1}...] I tried doing this an easier way with dec2bin(0:7,3) , but there doesn't seem to be a quick way to make the zeros into -1 s. Is there anything close to prepackaged that does this? In this case I don't want anyone to make it for me (related to homework). dec2bin is actually not the