octave

python vs octave random generator

China☆狼群 提交于 2019-12-10 03:34:15
问题 More specifically, numpy: In [24]: a=np.random.RandomState(4) In [25]: a.rand() Out[25]: 0.9670298390136767 In [26]: a.get_state() Out[26]: ('MT19937', array([1248735455, ..., 1532921051], dtype=uint32), 2,0,0.0) octave: octave:17> rand('state',4) octave:18> rand() ans = 0.23605 octave:19> rand('seed',4) octave:20> rand() ans = 0.12852 Octave claims to perform the same algorithm (Mersenne Twister with a period of 2^{19937-1}) Anybody know why the difference? 回答1: Unfortunately the MT19937

Matlab performance: comparison slower than arithmetic

不羁岁月 提交于 2019-12-10 01:52:37
问题 A while back I provided an answer to this question. Objective: count the number of values in this matrix that are in the [3 6] range: A = [2 3 4 5 6 7; 7 6 5 4 3 2] I came up with 12 different ways to do it: count = numel(A( A(:)>3 & A(:)<6 )) %# (1) count = length(A( A(:)>3 & A(:)<6 )) %# (2) count = nnz( A(:)>3 & A(:)<6 ) %# (3) count = sum( A(:)>3 & A(:)<6 ) %# (4) Ac = A(:); count = numel(A( Ac>3 & Ac<6 )) %# (5,6,7,8) %# prevents double expansion %# similar for length(), nnz(), sum(), %#

How to code a slider in Octave to have interactive plot?

烈酒焚心 提交于 2019-12-09 13:51:40
问题 my target is to have a plot that shows Stochastic oscillator on forex market, and in order to validate which parameter is the best one to setup it, I would use a slider to modify it and show updated result on plot. I have my historical data, for a defined pair (let say AUDUSD) and after loading it, I calculate Stocastic oscillator: function [stoch, fk, dk] = stochastic(n, k, d) X=csvread("AUDUSD_2017.csv"); C=X(2:length(X),5); L=X(2:length(X),4); H=X(2:length(X),3); O=X(2:length(X),2); for m

Creating animation with multiple plots - Octave/Matlab

烈酒焚心 提交于 2019-12-09 13:46:21
问题 I'm using Octave to write a script that plots a function at different time periods. I was hoping to create an animation of the plots in order to see the changes through time. Is there a way to do this so to possibly save each plot for each time in some way that each plot can be combined to create this animation? Thanks in advance for the advise! 回答1: This creates an animated gif data=rand(100,100,20); %100 by 100 and 20 frames %data go from 0 to 1, so lets convert to 8 bit unsigned integers

Indexing over all values in nested struct

≯℡__Kan透↙ 提交于 2019-12-09 03:49:26
问题 I have a nested struct which contains values and is defined as: mystruct.level1.a = 1; mystruct.level1.b = 2; mystruct.level2.a = 8; mystruct.level2.b = 9; I want to perform operations on the elements in level1 and level2. What I want to do is access the values in level1 and level2, put them in a vector, without referencing the nested field names. E.g. I'd like to do something like: level1_vector = [mystruct.level1] Which I would like to output: level1_vector = [1 2] How can I do that? 回答1:

Periodogram in Octave/Matlab vs Scipy

情到浓时终转凉″ 提交于 2019-12-08 23:45:27
问题 I am porting some matlab code to python using scipy and got stuck with the following line: Matlab/Octave code [Pxx, f] = periodogram(x, [], 512, 5) Python code f, Pxx = signal.periodogram(x, 5, nfft=512) The problem is that I get different output on the same data. More specifically, Pxx vectors are different. I tried different windows for signal.periodogram, yet no luck (and it seems that default scypy's boxcar window is the same as default matlab's rectangular window) Another strange

Is there a GNU Octave equivalent for the Matlab function “fit”?

天涯浪子 提交于 2019-12-08 19:49:48
问题 My teacher in the signal analysis course has given me some Matlab code that I have to execute in order to complete a home assignment. I have always been using GNU Octave without troubles, but this time there is this command that is giving me headaches. [c8,g8]=fit(time, sin_4_harmonic,’fourier8’) I cannot find the function "fit" in GNU Octave, which is referenced for Matlab at the following url http://www.mathworks.se/help/curvefit/fit.html Does anyone knows which package should I load, or if

How to increase font size for command window in octave

a 夏天 提交于 2019-12-08 18:50:49
问题 I was trying to figure out how to increase the command window text. I figured out legend : legend('{\fontsize{10} Low }', '{\fontsize{10} Medium }', '{\fontsize{10} High }') I tried doing the same thing, but with command , command_window , and other variations. I have tried to right click on octrave shortcut for the octave gui and set the font there to much larger. I am running Windows 8. 回答1: In the top left nav bar: octave-gui -> preferences -> Terminal -> Font Size NOT editor font size,

Ghostscript not writable

本小妞迷上赌 提交于 2019-12-08 18:08:18
问题 Trying to install octave on a new Macbook, but keep running into problems using Homebrew. I am following directions here: http://wiki.octave.org/Octave_for_MacOS_X I run into the error: Linking /usr/local/Cellar/ghostscript/9.14... Error: Could not symlink share/ghostscript/Resource /usr/local/share/ghostscript is not writable. After entering: sudo chown -R username:admin /usr/local/bin brew link ghostscript I still get the same error. How do I make ghostscript writable? 回答1: Using this

Octave - .m-File Compiler?

醉酒当歌 提交于 2019-12-08 17:36:03
问题 I know that with Matlab it is possible to compile the scripts / functions as an executable which can then be a standalone version together with Matlab Compiler Runtime. Is there any possible way to compile .m-files associated with octave as an executable program in a way that the .m-files aren't needed anymore for it to run? I would like to a have a standalone version of the script (possibility together with octave libraries / dlls) without the necessity of the .m-Files. 回答1: I believe it is,