octave

Error when running simple script containing local function in Octave

爱⌒轻易说出口 提交于 2019-11-28 01:37:39
问题 My file testtest.m looks like : pluse(1, 2) function retval = pluse(input1, input2) retval = input1 + input2; endfunction Then I get: error: 'pluse' undefined near line 1 column 1 error: called from testtest at line 1 column 1 Why do I get this error? 回答1: To answer your question properly, I need to point out two things: The canonical way to create a function in both octave and matlab is by placing it in a dedicated file by the same name, and starting the file with a function declaration .

Print Plot in Octave in Background

六眼飞鱼酱① 提交于 2019-11-28 00:00:15
Currently, I use print -dpng foo.png to print a plot to file in Octave 3.0.1 on Ubuntu. Sometimes, I generate thousands of images in a loop. Whenever a new image pops up, it grabs the mouse control precluding me from multitasking. Is there anyway to print silently or quietly? It would be easier to answer your question with a little more information about what you are doing. But with a little guessing maybe this is what you need: f = figure set(f, "visible", "off") plot([1,2,3,4]) print("MyPNG.png", "-dpng") 来源: https://stackoverflow.com/questions/6289807/print-plot-in-octave-in-background

How can I hot one encode in Matlab? [duplicate]

ぃ、小莉子 提交于 2019-11-27 22:28:18
This question already has an answer here: Create a zero-filled 2D array with ones at positions indexed by a vector 4 answers Often you are given a vector of integer values representing your labels (aka classes), for example [2; 1; 3; 3; 2] and you would like to hot one encode this vector, such that each value is represented by a 1 in the column indicated by the value in each row of the labels vector, for example [0 1 0; 1 0 0; 0 0 1; 0 0 1; 0 1 0] For speed and memory savings, you can use bsxfun combined with eq to accomplish the same thing. While your eye solution may work, your memory usage

Emacs change file extension - mode association

风格不统一 提交于 2019-11-27 22:16:33
问题 My Emacs opens .m files in ObjC mode. However I want to open them in Octave mode. I have already added to the .emacs file: (autoload 'octave-mode "octave-mod" nil t) (setq auto-mode-alist (cons '("\\.m$" . octave-mode) auto-mode-alist)) What else should I do? I do have Octave mode installed. 回答1: Fortunately everything is working now and unfortunately I don't remember how I fixed it :) Maybe there was an error in my .emacs earlier. This is the more correct code: (add-to-list 'auto-mode-alist

Gradient Descent implementation in octave

♀尐吖头ヾ 提交于 2019-11-27 19:57:35
问题 I've actually been struggling against this for like 2 months now. What is it that makes these different? hypotheses= X * theta temp=(hypotheses-y)' temp=X(:,1) * temp temp=temp * (1 / m) temp=temp * alpha theta(1)=theta(1)-temp hypotheses= X * theta temp=(hypotheses-y)' temp=temp * (1 / m) temp=temp * alpha theta(2)=theta(2)-temp theta(1) = theta(1) - alpha * (1/m) * ((X * theta) - y)' * X(:, 1); theta(2) = theta(2) - alpha * (1/m) * ((X * theta) - y)' * X(:, 2); The latter works. I'm just

Plot window not responding

喜欢而已 提交于 2019-11-27 17:12:08
I'm using Windows 7 64 bit. Each time, I'm using plot function, plot windows will shows and draws successfully, but after that it stops responding and must shut down it. For example : x = linspace(0,1,10) y = x.^2 plot(x,y); Strangely, when plot windows freeze and I must close octave windows, they will be unresponsive too. This will not happen if I don't use plot function. I don't know why. Does it because I'm using 64 bit version? Please tell me how to fix this. The problem is likely to be the graphics toolkit which your installation of Octave is using. To check this, type graphics_toolkit in

Principal Component Analysis in MATLAB

为君一笑 提交于 2019-11-27 16:30:18
问题 I'm implementing PCA using eigenvalue decomposition for sparse data. I know matlab has PCA implemented, but it helps me understand all the technicalities when I write code. I've been following the guidance from here, but I'm getting different results in comparison to built-in function princomp. Could anybody look at it and point me in the right direction. Here's the code: function [mu, Ev, Val ] = pca(data) % mu - mean image % Ev - matrix whose columns are the eigenvectors corresponding to

Interfacing octave with C#

时光毁灭记忆、已成空白 提交于 2019-11-27 15:44:49
问题 I have developed a program in Octave to which I would like to add a GUI layer. I want to create an executable program in C# that I can distribute but want to stick with the linear algebra constructs of Octave without having to implement them on my own. Particularly, I want basic matrix, vector operations and optimization functions (like fminunc and fmincg ). What is the best way to achieve this? Appropriate C# linear algebra library, perhaps? 回答1: There are lots of math libraries for c#. Math

Why is reshape so fast?

♀尐吖头ヾ 提交于 2019-11-27 14:23:43
I have a big matrix A which is 1GB of double values, when I reshape it to different dimensions, it's incredible fast. A=rand(128,1024,1024); tic;B=reshape(A,1024,128,1024);toc Elapsed time is 0.000011 seconds. How can it be that fast? Another observation, MATLAB uses less memory than it should after running that code and storing two matrices of 1GB each: Memory used by MATLAB: 1878 MB (1.969e+09 bytes) Explanation of the good performance Matlab uses copy-on-write whenever possible. If you write expressions like B=A , MATLAB does not copy A, instead both variables A and B are references to the

Octave plotting error

我怕爱的太早我们不能终老 提交于 2019-11-27 14:00:12
问题 I am new to octave, I just tried my first plotting with Octave 3.4.0 when I get the following error. Any help will be much appreciated. The gnuplot version is 4.6 octave-3.4.0:3> x=1:1:20; octave-3.4.0:4> y=sin(x); octave-3.4.0:5> plot(x,y) gnuplot> set terminal aqua enhanced title "Figure 1" size 560 420 font "*,6" ^ line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list The terminal window I am using for octave is the mac X-terminal. 回答1: Ok, I found the solution to