octave

How do I declare a symbolic matrix in Octave?

↘锁芯ラ 提交于 2019-12-21 07:05:28
问题 In MatLab, you can declare symbols pretty easily: syms a,b mat = [a,b] I'm getting an error, however, when I try to replicate this in Octave. This is the code I'm using: > symbols > a = sym("a") a = a > b = sym("b") b = b > mat = [a,b] error: octave_base_value::resize (): wrong type argument `ex' error: octave_base_value::resize (): wrong type argument `<unknown type>' octave-3.2.3.exe:4:C:\Octave\3.2.3_gcc-4.4.0\bin How do you declare a symbolic matrix in octave? 回答1: Would this help ? It

global variable in octave

最后都变了- 提交于 2019-12-21 04:28:23
问题 global m = 1; function p = h() m end h() I'm trying to run this script, but I get this error: 'm' undefined near line 4 column 3 Say me please, how I can use the variable from functions? 回答1: You have to declare the var also global inside the function as described here: https://www.gnu.org/software/octave/doc/interpreter/Global-Variables.html global m = 1; function p = h() global m; m endfunction h() 来源: https://stackoverflow.com/questions/27409364/global-variable-in-octave

Parallel computing in Octave on a single machine — package and example

Deadly 提交于 2019-12-20 19:05:51
问题 I would like to parallelize a for loop in Octave on a single machine (as opposed to a cluster). I asked a question about a parallel version of Octave a while ago parallel computing in octave And the answer suggested that I download a parallel computing package, which I did. The package seems largely geared to cluster computing, but it did mention single machine parallel computing, but was not clear on how to run even a parallel loop. I also found another question on SO about this, but I did

Zoom out in Octave / gnuplot

亡梦爱人 提交于 2019-12-20 08:21:47
问题 I use Octave with gnuplot under Windows. I can zoom in using the right mouse button. But how can I zoom out from the UI? 回答1: I found this post on Nabble. Pressing p takes you to the previous zoom level, n to the next level, and u unzooms. I pressed h in a gnuplot window outside of Octave and got this command list: 2x<B1> print coordinates to clipboard using `clipboardformat` (see keys '3', '4') <B2> annotate the graph using `mouseformat` (see keys '1', '2') or draw labels if `set mouse

Vectorized exponentiation

徘徊边缘 提交于 2019-12-20 04:47:39
问题 I have two vectors, X of bases and N of exponents. I want to get the matrix of all values e = x n for each x in X and n in N . For example, the following input: X = [2 3 4]' N = [1 2 3] should produce: ans = [2 4 8; 3 9 27; 4 16 64] Is there a way to get this without looping (just like you can get all values of x×n by using the column by row product)? 回答1: Use bsxfun: bsxfun(@power, X, N) This assumes that X is a column vector and N is a row vector. If you want to guarantee that, use the

Vectorized exponentiation

廉价感情. 提交于 2019-12-20 04:47:01
问题 I have two vectors, X of bases and N of exponents. I want to get the matrix of all values e = x n for each x in X and n in N . For example, the following input: X = [2 3 4]' N = [1 2 3] should produce: ans = [2 4 8; 3 9 27; 4 16 64] Is there a way to get this without looping (just like you can get all values of x×n by using the column by row product)? 回答1: Use bsxfun: bsxfun(@power, X, N) This assumes that X is a column vector and N is a row vector. If you want to guarantee that, use the

Are there C like pre-processor directives for Octave and Scilab to be used for intercompatible code?

我的梦境 提交于 2019-12-20 04:07:55
问题 In C / C++ languages one can use macros or as called "per-processor directives" to instruct the compiler how the code should be read. The simple commands of #def , #ifdef , #ifndef , #else , #endif ... give the compiler the ability to check for Operating system, compiler and other environment information. I know Octave and Scilab are interpreted languages, but I'm wondering if is there any way to tell the interpreter to replaces parts of script while loading it? For example can I write a code

Octave doesn't plot from external file

你。 提交于 2019-12-20 02:29:11
问题 If I type octave on terminal and then: x = linspace(0, 2*pi, 100); y = sin(x); plot(x, y); the graphic correctly shows the plot. That's what I tried: I created a text file named gettingStarted.m where I wrote the three lines above inside of it, in order to execute this file with Octave. I type octave gettingStarted.m but the plot doesn't appear. Does not plotting work if you run an external file with Octave? I'm working on Ubuntu 12.04, 32 bit 回答1: If you are running an Octave script that

How to multiply two rows or columns?

白昼怎懂夜的黑 提交于 2019-12-20 01:59:07
问题 a = [1, 2, 3]; b = [3, 2, 1]; c = a * b; yields error: operator *: nonconformant arguments (op1 is 1x3, op2 is 1x3) Why can I not multiply these two rows of the same size? I shouldn't have to run a for loop for this, but I don't know of another way... I saw section 1.2.3 here, which indicates (to me at least) that I should be able to do it . 回答1: You made 2 rows, which can't be multiplied together. The general form of matrix multiplication is " Row-Dot-Column ", which means take the dot

urlread(), urlwrite() don't work for https pages in Octave for Windows

末鹿安然 提交于 2019-12-19 22:00:49
问题 When I use Octave 3.8.1 installed in Cygwin, I can successfully download https pages like this: urlwrite('https://www.google.com', 'downloaded.html') However, when I use Octave 3.6.4 installed in Windows 7 SP1 Pro 64bit, urlwrite() doesn't work: octave-3.6.4.exe:18> urlwrite('https://www.google.com', 'downloaded.html') error: urlwrite: curl: Problem with the SSL CA cert (path? access rights?) urlread() has the same problem. Is there a good way to avoid this error? Update: Following Andy's