octave

import function in octave

不问归期 提交于 2019-12-19 19:55:28
问题 I am running matlab code in octave. The import function is not implemented in core octave, I guess. Any idea how to use this matlabe function in octave? Here is what I have: octave-3.4.0:7> setup Importing packages: brml.* warning: the `import' function is not yet implemented in Octave Please read `http://www.octave.org/missing.html' to learn how you can contribute missing functionality. error: `import' undefined near line 8 column 5 回答1: You can make your own custom import.m. From http:/

Creating an m by n matrix of 0s and 1s from m-sized vector of column indexes

我怕爱的太早我们不能终老 提交于 2019-12-19 19:12:21
问题 I have a m -dimensional vector of integers ranging from 1 to n . These integers are column indexes for m × n matrix. I want to create a m × n matrix of 0s and 1s, where in m -th row there's a 1 in the column that is specified by m -th value in my vector. Example: % my vector (3-dimensional, values from 1 to 4): v = [4; 1; 2]; % corresponding 3 × 4 matrix M = [0 0 0 1; 1 0 0 0; 0 1 0 0]; Is this possible without a for-loop? 回答1: Of course, that's why they invented sparse matrices: >> M =

Creating an m by n matrix of 0s and 1s from m-sized vector of column indexes

隐身守侯 提交于 2019-12-19 19:12:20
问题 I have a m -dimensional vector of integers ranging from 1 to n . These integers are column indexes for m × n matrix. I want to create a m × n matrix of 0s and 1s, where in m -th row there's a 1 in the column that is specified by m -th value in my vector. Example: % my vector (3-dimensional, values from 1 to 4): v = [4; 1; 2]; % corresponding 3 × 4 matrix M = [0 0 0 1; 1 0 0 0; 0 1 0 0]; Is this possible without a for-loop? 回答1: Of course, that's why they invented sparse matrices: >> M =

Loopless function calls on vector/matrix members in Matlab/Octave

爱⌒轻易说出口 提交于 2019-12-19 19:03:52
问题 I came into matrix world from loop world (C, etc) I would like to call a function on each individual member of a vector/matrix, and return the resulting vector/matrix. This is how I currently do it: function retval = gauss(v, a, b, c) for i = 1:length(v) retval(i) = a*(e^(-(v(i)-b)*(v(i)-b)/(2*c*c))); endfor endfunction Example usage: octave:47> d=[1:1000]; octave:48> mycurve=gauss(d, 1, 500, 100); Now, all advice on MATLAB/Octave says: STOP whenever you catch yourself using loops and think

Octave plot from Qt C++ application

陌路散爱 提交于 2019-12-19 08:57:53
问题 I have a QT C++ application that runs the Octave program using QProcess. I am able to communicate with it by reading the standard output/error and writing to it's standard input using write method (for example: octave->write("5 + 5\n");). As I told you I get response from octave (from the above example I get "ans = 10"). However, when the command I write to Octave standard input has a "plot" (for example, a simple plot([1 2 3 4 5]);), the actual graphic is never shown. I know Octave runs

Domain coloring (color wheel) plots of complex functions in Octave (Matlab)

非 Y 不嫁゛ 提交于 2019-12-19 04:24:38
问题 I understand that domain or color wheel plotting is typical for complex functions. Incredibly, I can't find a million + returns on a web search to easily allow me to reproduce some piece of art as this one in Wikipedia: There is this online resource that reproduces plots with zeros in black - not bad at all... However, I'd like to ask for some simple annotated code in Octave to produce color plots of functions of complex numbers. Here is an example: I see here code to plot a complex function.

Domain coloring (color wheel) plots of complex functions in Octave (Matlab)

风格不统一 提交于 2019-12-19 04:24:09
问题 I understand that domain or color wheel plotting is typical for complex functions. Incredibly, I can't find a million + returns on a web search to easily allow me to reproduce some piece of art as this one in Wikipedia: There is this online resource that reproduces plots with zeros in black - not bad at all... However, I'd like to ask for some simple annotated code in Octave to produce color plots of functions of complex numbers. Here is an example: I see here code to plot a complex function.

Plotting FFT on octave

风格不统一 提交于 2019-12-18 15:00:27
问题 I know that FFT changes a function in the time domain to one showed in the frequency domain. However, when I try plotting said graph in the frequency domain, I can only get it to work properly by using the time as X-axis, when it was obviously supposed to be not that, but the frequency. Also, I can only get the amplitudes to match the ones in the original signal by dividing the y-axis by a certain integer. Why is that? Here's my code t=0:0.001:2 x=2*sin(20*pi*t) + sin(100*pi*t) subplot(2,1,1)

How can I get a list of all the defined variables in Matlab or Octave?

人盡茶涼 提交于 2019-12-18 12:47:25
问题 I'm used to working in Matlab using its full GUI environment. Due to license issues I went and installed Octave, but it appears that it doesn't have a GUI, at least not one that's installed by default. I transferred the variables from Matlab to Octave by save ing them in Matlab and load ing them in Octave. Thing is, I don't remember the names because I got used to seeing them in the little workspace window which I no longer have. How can I see the list of defined variables and their types in

fminunc alternate in numpy

一世执手 提交于 2019-12-18 10:14:09
问题 Is there an alternative to the fminunc function (from octave/matlab) in python? I have a cost function for a binary classifier. Now I want to run gradient descent to get minimum value of theta. The octave/matlab implementation will look like this. % Set options for fminunc options = optimset('GradObj', 'on', 'MaxIter', 400); % Run fminunc to obtain the optimal theta % This function will return theta and the cost [theta, cost] = ... fminunc(@(t)(costFunction(t, X, y)), initial_theta, options);