octave

How do I use map with custom function in Octave?

百般思念 提交于 2019-12-08 16:25:23
问题 Assume I have a collection A : A = [0:6:100] And I have a function fib(n) : function retval=fib(n) g1=(1+5^.5)/2 g2=(1-5^.5)/2 retval=(1/5^.5)*(g1^n - g2^n) endfunction I intend to be able to apply fib(n) on A , and store it in a collection say B, where B[i,j] is (i,fib(i)) , so I can plot i vs fib(i) and see the results on a graph. Please advise on how I can use map to obtain this desired collection B . 回答1: You can do it like this: map(@fib, A) The @ makes fib into a function handle. Note

How can I suppress the output of a command in octave?

孤街醉人 提交于 2019-12-08 15:47:08
问题 In Octave I can suppress or hide the output of an instruction adding a semicolon to the end of a line: octave:1> exp([0 1]) ans = [ 1.0000 2.7183 ] octave:2> exp([0 1]); octave:3> Now, how can I suppress the output if the function displays text (e.g. using disp() or print() ) before returning its value? In other words, I want to be able to do this: disp("Starting..."); % hide text the may get displayed after this point % ... % show all text again after this point disp("Done!"); 回答1: You can

How to draw a circle in GNU Octave

跟風遠走 提交于 2019-12-08 15:40:41
问题 In Matlab you can draw a circle by just specifying the center and the radius like this: R = 10; Center = [5,8]; circle(Center,R,1000,'b-'); hold on plot(Center(1),Center(2),'g.') The same code for MatLab won't work for GNU Octave. What octave code would draw a circle given a center x,y coordinates and a radius? 回答1: t = linspace(0,2*pi,100)'; circsx = r.*cos(t) + x; circsy = r.*sin(t) + y; plot(circsx,circsy); 回答2: Using the octave extra package octave-geometry you can use the function

how to use Vlfeat in Octave in window 7?

六眼飞鱼酱① 提交于 2019-12-08 10:58:21
问题 I use octave and want to use Vlfeat to do my project in Windows 7. The website has suggestion to use from Octave as below: I complete to install package image according to the code in green (first) box. However, I've got stuck to the code in red (second) box. Is the code in red box used in Octave or in Windows command prompt? If No, Where should I use it? Is it in Ubuntu command prompt? I am not accustomed to Ubuntu. To use it without Ubuntu would be much appreciated (Although I have some

Force octave to use command line [closed]

瘦欲@ 提交于 2019-12-08 09:58:17
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Before upgrading my ubuntu install to 16.04 invoking 'octave' would open the octave interpreter, useful as a powerful calculator. Now, typing octave opens the octave gui. I need to type 'octave --no-gui' to get my interpreter back.' Why does this happen? How can I restore 'octave' opening the interpreter? 回答1:

Using interpolation and repmat to change frequency of signal in octave and matlab

与世无争的帅哥 提交于 2019-12-08 09:39:51
问题 I'm using Octave 3.8.1 which is like matlab, I'm trying to use interpolation and repmat to alter the frequency of signals ( since it's so fast doing it this way (.01 seconds) and I have to create 28000+ at a time ) I can change the variable num_per_sec to any whole number but if I try to change it to 2.1 or anything with a decimal in it I get an error "error: reshape: can't reshape 44100x2 array to 92610x1 array error: called from: line 10 (the repmat line)" does anyone have a work around for

Time stretching signal / porting python code to matlab / octave

[亡魂溺海] 提交于 2019-12-08 09:28:56
问题 I'm trying to port over paulstretch's signal stretching over to matlab / octave. https://github.com/paulnasca/paulstretch_python See workflow i'm following below I can separate the signals into frequencies, amplitude and phase and join them back using the code below. I'm having issues porting over the windowing segments, overlapping, and extending the signals. Any ideas? Example matlab / octave code: freq=[0;0.534974;1.06995;1.60492;2.1399] amp1=[3.94414e-19;1.20523e-05;5.08643e-06;4.22469e

how to convert Matlab scripts in R

拥有回忆 提交于 2019-12-08 06:19:41
问题 I would like to run some Matlab scripts. Nevertheless we don't have the Matlab licence so it is necessary a conversion from Matlab to R language. Unfortunately I'm totally new in Matlab but not in R. Is it possible to read Matlab scripts using R or is there an easy way to translate Matlab scripts in R? 回答1: Rewriting from one language to another can be a painstaking process, especially because your have to take great care that the outcomes of both sets of codes are the same. I see roughly

How is a global matrix different?

妖精的绣舞 提交于 2019-12-08 06:07:18
问题 This computes fine: spike(waves0); But this surprisingly doesn't: toArff(@spike) error: A(I): Index exceeds matrix dimension. error: called from: error: /Users/simpatico/mlr/spike.m at line 4, column 7 error: /Users/simpatico/mlr/toArff.m at line 4, column 16 function toArff = toArff(features) global waves0; spike0 = features(waves0); true = zeros(size(waves0)(1), 1); P = [spike0 true]; end 回答1: You need to declare waves0 as global in the base workspace first. Alternatively, you can use the

Call GNU Octave functions in C?

▼魔方 西西 提交于 2019-12-08 05:55:29
问题 I want to use matrix algebra and optimization. I have tested different C and C++ libraries for matrix algebra but the problem with those is they cannot handle garbage data as good as GNU Octave does. Garbage data in C and C++ goes low to like e-8 but in GNU Octave it will be pushed down way to low as e-17. That's very useful if you planning to use garbage data from e.g measurement in calculations. They don't effect nothing of your results. But GNU Octave have a C++ API, which I don't really