octave

How to know what word appears most in a paragraph? (Matlab)

橙三吉。 提交于 2019-12-05 18:32:43
I have a huge paragraph and want to know what word appears most in it. Could anyone please point me in the right direction with this? Any examples and explanations would be helpful. Thanks! X'' Here is a simple solution, should be quite fast. example_paragraph = 'This is an example corpus. Is is a verb?'; words = regexp(example_paragraph, ' ', 'split'); vocabulary = unique(words); n = length(vocabulary); counts = zeros(n, 1); for i=1:n counts(i) = sum(strcmpi(words, vocabulary{i})); end [frequency_of_the_most_frequent_word, idx] = max(counts); most_frequent_word = vocabulary{idx}; You can also

Octave JIT compiler. Current state, and minimal example demonstrating effect

為{幸葍}努か 提交于 2019-12-05 18:31:09
I hear very conflicting information about Octave's experimental JIT compiler feature, ranging from "it was a toy project but it basically doesn't work" to "I've used it and I get a significant speedup". I'm aware that in order to use it successfully one needs to Compile octave with the --enable-jit at configure time Launch octave with the --jit-compiler option Specify jit compilation preference at runtime using jit_enable and jit_startcnt commands but I have been unable to reproduce the effects convincingly; not sure if this is because I've missed out any other steps I'm unaware of, or it

Converting MATLAB files to Octave

不问归期 提交于 2019-12-05 18:11:34
I have a series of experiments that were written for MATLAB, but recently we are trying to run them through Octave instead. I realize they are mostly compatible, but I have been running into a few problems, and none of the online FAQs or directions I have found have addressed these at all. It's complicated a bit because there are multiple .m files that interact; however, for now I am going to focus on the main program. Anyway, so when I try to run the file (MLP.m) through octave, I get the following errors in the Terminal window: error: dir: expecting directory or filename to be a char array

what is the purpose of the @ symbol in front of a variable in octave?

♀尐吖头ヾ 提交于 2019-12-05 18:07:31
问题 For example: model = svmTrain(X, y, C, @(x1, x2) gaussianKernel(x1, x2, sigma)); Disclaimer: This is from the Coursera ML class, but it's nearly impossible to search for the @ symbol conventionally. 回答1: @ prefixes the definition of an anonymous function. 回答2: Also, @ is used to demark a function handle. 来源: https://stackoverflow.com/questions/25355028/what-is-the-purpose-of-the-symbol-in-front-of-a-variable-in-octave

Animate trajectory using Octave

我是研究僧i 提交于 2019-12-05 17:43:32
I have a set of (x,y) coordinates that describe the trajectory of an object. I'd like to animate this trajectory using GNU Octave. The data set is quite large so I won't be able to redraw the entire plot at every iteration if I want the animation to be smooth. What functions are there that would allow me to "update" a plot rather than redraw it? Also, I have another set of (vx,vy) points, which describe the speed of the object. I'd like my animated trajectory to take speed into account. What function should I use to have the program sleep for a couple of milliseconds as to make the trajectory

Octave GNU: Undefined variable 'x' , even though it's defined as function input

可紊 提交于 2019-12-05 16:49:49
just trying to write a simple program to find the gcd of n numbers. I have no clue how to fix this error, i've read all of octaves function documentation and tried to find questions like this ... Just started programming in Octave btw. Here's the code: function divisor = gcd(x, y) q=0; r=0; l=0; h=0; if(x>y) h=x; l=y; elseif(x<y) h=y; l=x; else h=y; l=x; endif while(r != 0) q=floor(h/l); r = h-l*q; q=h; r=l; endwhile divisor = q; printf("%d", q); return; endfunction The Error: error: 'x' undefined near line 6 column 6 error: called from gcd at line 6 column 3 Thank you :) Your code is a

How to change toolkit in Octave?

耗尽温柔 提交于 2019-12-05 16:41:38
My Octave crashes when I execute plot command. I found a solution in Assad Ebrahim's answer . He mentioned to switch the default toolkit to gnuplot , and change it in octave.rc file if I want to make the change permanently but I'm not clear about the permanent change in octaverc . When I open my octaverc with notepad++, it looks like this: ## System-wide startup file for Octave. ## ## This file should contain any commands that should be executed each ## time Octave starts for every user at this site. EXEC_PATH (cstrcat (fullfile (OCTAVE_HOME, 'notepad++'), pathsep, EXEC_PATH)); EXEC_PATH

Octave plot points as animation

与世无争的帅哥 提交于 2019-12-05 13:38:01
I have the following octave script, TOTAL_POINTS = 100; figure(1) for i=1:TOTAL_POINTS randX = rand(1); randY = rand(1); scatter(randX, randY); hold on; endfor When I run this by octave script.m , I get nothing. When I add the line pause to the end of this script, it works but I only see the plot after all the 100 points are plotted. I want to see the plot point by point. Not after I plotted every single point. PS: I have Ubuntu . Try adding drawnow at the end of the iteration. At least that works in Matlab. It forces the interpreter to empty the graphic event queue. If you include pause at

Setting transparancy of surface plot on Octave

老子叫甜甜 提交于 2019-12-05 13:22:59
I am running Octave 3.4.0 and want to create a transparent surface plot. However, I have not been able to do so when messing around with facealpha , edgealpha , alphadata and alphadatamapping . Example code for creating a non-transparent surface: p = peaks(40); f1 = figure(10);clf s1 = surface(p) view(3) xlabel('x');ylabel('y'); hold on;plot3([0 40],[40 0],[-10 10],'k') set(s1,'edgecolor','none') set(s1,'facealpha',0.2) The result of this given in the image below. As you can see, the line drawn diagnonlly at the start is hidden behind the surface, even though the surface is suppose to be semi

GNU Octave, round a number to units precision

萝らか妹 提交于 2019-12-05 12:38:31
问题 In GNU Octave version 3.4.3 I want to round a matrix to 2 units precision on the contents of a matrix like this. mymatrix=[1.1234567, 2.12345; 3.1234567891, 4.1234]; disp(mymatrix); This prints: 1.1235 2.1235 3.1235 4.1234 As you can see, the disp forces the precision to '5', I want the units precision to be 2. How do I do this? 回答1: How to round off elements in a matrix in Octave: There are many different ways to round a matrix and round a number in octave. Option 1, use of sprintf format