octave

Octave strcat ignores added spaces

不想你离开。 提交于 2019-12-10 19:20:03
问题 Octave adds spaces with strcat In Octave I run these commands: strcat ("hel", " ", "lo") I get this result: ans = hello Instead of what I expected: ans = hel lo strcat to me sounds like "concatenate strings". A space is a valid character, so adding a space should be OK. Matlab has the same behaviour, so it's probably intended. I find it counter intuitive. Does this behavior makes sense? 回答1: Hmm. It works how it is defined: "strcat removes trailing white space in the arguments (except within

Playing an array as sound and recording its output in parallel

时光怂恿深爱的人放手 提交于 2019-12-10 18:56:20
问题 I know Octave/MATLAB can play arrays as sound, but I was wondering if Octave can do this: I would like to cycle through a range of frequencies and have Octave play them using the speaker out on my computer, and have Octave also record the sound using the microphone input to get the max value. I'm trying to automate a way to have Octave cycle through frequencies and record the data received so I can go back later and look at the resonant frequencies. Can Octave do this type of operation in

mkoctfile Segmentation Fault

筅森魡賤 提交于 2019-12-10 18:14:55
问题 I'm trying to compile an example mex file in Octave and get the following error that I don't understand and can't find where to go for more information: octave:8> mkoctfile -v --mex hello_oct.cpp /usr/local/octave/3.8.0/bin/mkoctfile-3.8.0: line 512: 15840 Segmentation fault: 11 /usr/local/octave/3.8.0/bin/g++-mp-4.7 -c -fPIC -I/usr/local/octave/3.8.0/include/octave-3.8.0/octave/.. -I/usr/local/octave/3.8.0/include/octave-3.8.0/octave -I/usr/local/octave/3.8.0/include -pipe -Os -m64 -D_THREAD

How to use Octave libraries with C++

邮差的信 提交于 2019-12-10 18:05:38
问题 This is my first question here, so sorry in forward if it is not well formulated or stupid. I am trying to use the octave libraries with C++ I am using Qt creator on Ubuntu (linux noob) #include "octave/oct.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); Matrix matrix(3,4); return a.exec(); } At first I got some undefined references errors. I figured out the program is missing libraries, so I looked for the library "liboctave.so". I found it in usr/lib/octave-3.2.4. To be

Exit loop at the end of current iteration step if condition is fulfilled

时光毁灭记忆、已成空白 提交于 2019-12-10 18:02:39
问题 A common problem I have is the following: Within a loop (usually a for loop) some constraints are - and have to be - checked at the beginning . Now sometimes if a condition if fulfilled, the code within the loop should run to the end of the current iteration step and then quit . Usually I'd do it somehow like so a = 0; quit = 0; for i = 1:1:11 if (a == 5) % Condition to be checked *before* the calculation quit = 1; % Stop loop after this iteration end a = a + 1; % Calculation ... if (quit ==

Set modification time in matlab

笑着哭i 提交于 2019-12-10 17:35:09
问题 I can get modification time in matlab by: >> f = dir('my_filename.dat'); >> f.date But how can I change it? 回答1: This is can be done using Java&Matlab: import java.io.File java.text.SimpleDateFormat f = File('my_filename.dat'); sdf = SimpleDateFormat('HH:mm dd/MM/yyyy'); newDate = sdf.parse('12:34 10/12/2010'); f.setLastModified(newDate.getTime); 回答2: To set the date to the current date you can write something to the file: fid = fopen('my_filename.dat', 'r+'); byte = fread(fid, 1); fseek(fid,

1-of-K coding in Octave

半城伤御伤魂 提交于 2019-12-10 17:29:44
问题 I'm trying to get a binary one-of-K coding of a integer vector in Octave. I've got a vector y , say y = [1 ; 2 ; 3 ; 1 ; 3] and I want a matrix Y = [1 0 0 0 1 0 0 0 1 1 0 0 0 0 1] I can construct the one-of-K matrix by hand with Y = []; Y = [Y y == 1]; Y = [Y y == 2]; Y = [Y y == 3]; But when I try to construct it with a for loop, Y = []; for i = unique(y), Y = [Y y == i]; endfor something goes wrong: error: mx_el_eq: nonconformant arguments (op1 is 5x1, op2 is 3x1) I don't even understand

octave/matlab - convert string into matrix of unique words

坚强是说给别人听的谎言 提交于 2019-12-10 17:12:20
问题 In Octave, I want to convert a string into a matrix of strings. Say I have a string: s = "one two three one one four five two three five four" I want to split it into a matrix so that it looks like: one two three four five With duplicates removed. This code: words = strsplit(s, ",") %Split the string s using the delimiter ',' and return a cell string array of substrings Just creates a matrix words into exactly the same as s . How to I convert my string into a matrix of unique words? 回答1: The

List of all built-in symbols in Matlab/Octave

馋奶兔 提交于 2019-12-10 15:55:45
问题 In Mathematica one can get the names of all built-in functions starting with, for instance, List by executing the command Names["List`*"] In addition Names["context`*"] lists all symbols in the specified context. E.g. Names["Global`*"] gives the names of all the built-in symbols (as well those defined by the user in Global context if any). Are there similar structures in Matlab/Octave? 回答1: In Octave you can use the following functions: __operators__ : Undocumented __keywords__ : Undocumented

Identifying (and removing) sequences from a vector in Matlab/Octave

前提是你 提交于 2019-12-10 15:21:58
问题 I'm trying to prune any sequence of length 3 or more from a vector of numbers in Matlab (or Octave). For example, given the vector dataSet , dataSet = [1 2 3 7 9 11 13 17 18 19 20 22 24 25 26 28 30 31]; removing all sequences of length 3 or more would yield prunedDataSet: prunedDataSet = [7 9 11 13 22 28 30 31 ]; I can brute force a solution, but I suspect there is a more succinct (and perhaps efficient) way to do it using vector/matrix operations, but I always get confused about whether