octave

Octave plot from Qt C++ application

不羁的心 提交于 2019-12-01 07:49:10
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 gnuplot, I have it installed, and gnuplot_x11 too. I even change the gnuplot binary path in my Octave

Insert rows and columns of zeros between every row column

£可爱£侵袭症+ 提交于 2019-12-01 07:29:54
问题 If i have a MxN matrix, how do i add(not replace) a row of zeros and a column of zeros after every other column/row in the original matrix in matlab? Effectively the result would be 2Mx2N. 回答1: You can do it in the following way. Do not add the new rows and columns but create an empty matrix and fill the elements from the original matrix. Create a new matrix with the dimensions 2Mx2N B = zeros(2*size(A)); (assuming that A is your original matrix). Using B(1:2:end,1:2:end) = A; should result

Run octave script file containing a function definition

点点圈 提交于 2019-12-01 07:07:49
问题 I've a very newbie octave question. Running this code in octave console is working fine: function fibo = recfibo(n) if ( n < 2 ) fibo = n; else fibo = recfibo(n-1) + recfibo(n-2); endif endfunction disp(recfibo(5)) By inserting this code in an external file named for example file.m , and executing it through octave file.m an error occurs: warning: function name 'recfibo' does not agree with function filename '/Users/admin/Google Drive/file.m' error: 'n' undefined near line 2 column 8 error:

ignoring return value syntax?

爱⌒轻易说出口 提交于 2019-12-01 06:16:17
In Matlab, the tilda symbol can be used to ignore a certain parameter from a function that returns multiple parameters. However, when I try the same code in Octave, I get a syntax error. I have two questions: Why does Octave not support this? (i.e. bug, future enhancement, design decision, etc.) What's the alternative syntax in Octave, if any (without just putting a "dummy variable" into the spot then clearing that variable)? Additionally, is this alternative syntax Matlab compatible? % this is valid Matlab code, but will result in a syntax error in Octave [colA, colB, ~, colC] = textread(

MATLAB/OCTAVE Extracting elements from different sized vectors in a cell array

て烟熏妆下的殇ゞ 提交于 2019-12-01 04:59:25
问题 I have a simple question but I can't figure it out or find it anywhere. I have a cell array where c{1} is a vector and c{2} is a vector but of different lengths, up to c{i}. What I want is one vector that is [c{1};c{2};c{3}...c{i}]. What is the most efficient way to do this? 回答1: The following one-liner even works for completely inconsistent inputs: result = [cell2mat(cellfun(@(x) x(:), A, 'uni', 0)')]' Example: for: A{1} = [1, 2, 3, 4, 5]; A{2} = [6; 7; 8; 9]; A{3} = [10, 12; 11, 13]; it

Character-mode (shell/ASCII) plots with Octave scripts

﹥>﹥吖頭↗ 提交于 2019-12-01 04:53:10
问题 When running Octave in an interactive shell session, I know I can display character-mode / ASCII plots, as discussed here: Character-mode (shell) plots with Matlab / Octave? My problem is that I'd like to have that kind of output when my octave script is run non-interactively. That is, I'd like to be able to run something like the following: #!/usr/bin/octave -qf plot(sin(0:7)) And have output along the lines of : 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > + ---+ + + + + > > +---

BLAS and LAPACK libraries required for compiling

◇◆丶佛笑我妖孽 提交于 2019-12-01 04:43:22
I recently downloaded the latest stable release of Gnu Octave, and was attempting to build and install it on my machine (Ubuntu 10.0.4 LTS 64bit). When I run ./configure, I got this error message: configure: error: You are required to have BLAS and LAPACK libraries Does anyone know Where do I obtain these libraries from? Try to run this apt-get install libblas-dev libatlas-dev liblapack-dev All libraries, required by octave package in ubuntu are listed here: http://packages.ubuntu.com/lucid/octave3.2 and to build new octave you need -dev packages of some listed libs. The octave in ubuntu

MATLABs 'fminsearch' different from Octave's 'fmincg'

 ̄綄美尐妖づ 提交于 2019-12-01 04:14:20
问题 I am trying to get consistent answers for a simple optimization problem, between two functions in MATLAB and Octave. Here is my code: options = optimset('MaxIter', 500 , 'Display', 'iter', 'MaxFunEvals', 1000); objFunc = @(t) lrCostFunction(t,X,y); [result1] = fminsearch(objFunc, theta, options); [result2]= fmincg (objFunc, theta, options); (Bear in mind, that X, y, and theta are defined earlier and are correct). The problem is the following: When I run the above code in MATLAB with it using

How do you perform conditional assignment in arrays in Julia?

会有一股神秘感。 提交于 2019-12-01 03:39:48
In Octave, I can do octave:1> A = [1 2; 3 4] A = 1 2 3 4 octave:2> A(A>1) -= 1 A = 1 1 2 3 but in Julia, the equivalent syntax does not work. julia> A = [1 2; 3 4] 2x2 Array{Int64,2}: 1 2 3 4 julia> A[A>1] -= 1 ERROR: `isless` has no method matching isless(::Int64, ::Array{Int64,2}) in > at operators.jl:33 How do you conditionally assign values to certain array or matrix elements in Julia? Your problem isn't with the assignment, per se, it's that A > 1 itself doesn't work. You can use the elementwise A .> 1 instead: julia> A = [1 2; 3 4]; julia> A .> 1 2×2 BitArray{2}: false true true true

Installing octave package in ubuntu

可紊 提交于 2019-12-01 03:12:01
anyone can help me with this error? octave:4> pkg install signal-1.2.0.tar.gz error: the following dependencies where unsatisfied: signal needs optim >= 1.0.0 signal needs specfun >= 0.0.0 signal needs control >= 2.2.3 signal needs general >= 1.3.2 octave:4> pkg install optim-1.2.2.tar.gz error: the following dependencies where unsatisfied: optim needs miscellaneous >= 1.0.10 optim needs struct >= 1.0.10 octave:4> pkg install struct-1.0.10.tar.gz make: /usr/bin/mkoctfile: Command not found make: *** [fields2cell.oct] Error 127 'make' returned the following error: make: Entering directory `/tmp