/r/octave

Photograph via snooOG

Subreddit for discussing topics and questions related to GNU Octave.

Now back open for business!

GNU Octave is a high-level interpreted language, primarily intended for numerical computations. It provides capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments. It also provides extensive graphics capabilities for data visualization and manipulation. The Octave language is quite similar to Matlab so that most programs are easily portable.

Related Subreddits

/r/octave

1,570 Subscribers

3

How to integrate with multiple variable, but with respect to a single one

Let's say I have f(x)=x+y and I want to integrate with respect to x from 0-3, which should give me 9/2+3y. I can't seem to figure out how to do that though, any ideas? I tried this code,

function g = f(x)
  g = x+y;
endfunction
[q, ier, nfun, err] = quad('f',0,3)

Which gives this error:

error: quad: evaluation of user-supplied function failed
error: called from
    f at line 2 column 5
    octave-test.m at line 4 column 21
5 Comments
2022/10/14
03:45 UTC

1

ans variable can't be cleared after using csvread

I've written a short script that creates a cell array and adds a new cell for each csv file that I choose. The script keeps looping so I can keep choosing csv files. It stops when I push cancel in the file browsing window that pops up.

I'm seeing strange behavior with the ans variable. First off, I've put a semicolon after every line so I don't know why ans is created. Secondly, even if I type "clear ans" in the command line, ans is deleted and then immediately reappears. The value of ans is one of the csv files I browsed.

If I type "3+4" into the command line, it returns "ans = 7" and I can see that ans changes to 7 momentarily, but then ans right away changes to what it was before. I don't understand what could be causing ans to change.

Here's the script.

%% Data Loader v2
%
% Oct 7, 2022

% Choose Data Name in the save function below!

[fname, fpath] = uigetfile();
i = 1;
while fpath ~= 0
  Test11_late{i} = csvread(strcat(fpath, fname));
  i = i + 1;
  [fname, fpath] = uigetfile();
end

clearvars -except Test11_early Test11_late;

% Set data name in the first argument below. Keep the quotes.
save(strcat("Test11", ".mat"));

Here's my workspace after running the script and choose two csv files.

https://i.imgur.com/EhgKm6P.png

I can probably work around this, but I'm really curious about what's going on. Any ideas are welcome! Thanks!

EDIT: Since ans was one of the csv files I chose, I wanted to see if it would change based on the order I chose the csv files and now I cannot get the behavior to happen. This issue was plaguing me yesterday, and today, and now that I've created this thread and changed the order I choose the csv files, I can't get it to do it at all anymore. Even when I go back to the original order I was choosing them.

I have no explanation.

0 Comments
2022/10/11
18:28 UTC

2

Octave code help needed

I am not able to overcome this problem no matter what I try. I don't see anything wrong IM doing but yea I'm sure there is. Please help and thank you so much!

The code

The error script

The Original equations

I've been stuck at this for 2 weeks and this is part of my research project. Please do explain in newbie language (if you're sharing the final codes that's fine too hehe)

1 Comment
2022/10/09
23:59 UTC

8

Is there any way to run octave in android for free?

Hello

I used octave in termux before but it doesn't work now. The old apks don't work, and the new app costs money. what other options are there?

Thanks for reading :)

6 Comments
2022/10/06
20:17 UTC

2

Defining N many (N,1) vectors each of which is a column of eye(N)

I want a code such that if I fix N = 42 (e.g.), for any i between 1 to N, if I enter A_i in the command line, I get the output eye(N)(:, i).

I would like to avoid defining them by hand.

4 Comments
2022/09/29
10:35 UTC

7

Interesting code to create animated GIFs in Octave

1 Comment
2022/09/26
17:57 UTC

1

Octave code help needed!

Alright, so part of my research involves me using octave gnu to solve basic ODEs. But I don't think I have this figured out. It may be my conceptual theory that lacks or the stupid syntaxes that are confusing me but here please take a look and tell me why this ain't working. And please speak in English as I'm kinda boomer k thnx :')

Codes since I'm not able to upload pictures smh

The code

The reason you see me doing stuff twice and commenting it all, is because I wanted to try which works and which don't, like either doing all ODEs in 1 function or separate functions. Eitherway right now I'm not able to move past the first step. What am i doing wrong. Please do help. I shall attach the error response below too for reference. Thank you soo much!

Error script :(

4 Comments
2022/09/23
13:18 UTC

2

Question: Defining a symbolic function involving symbolic tensors with indices and kroneckerDelta

2 Comments
2022/09/20
09:15 UTC

3

Can't open Octave GUI on Windows

[SOLVED]

I open Octave by clicking on the shortcut and the window appears, sometimes showing the program, other times just white, and it turns off in a couple of seconds... Sometimes it happens to open and it works like normal, but that's rare, like 1 in 20 times. I had installed it a few days ago and used it normally, the version was 7.2.0, now I got 7.1.0 but still can't run it.

Another clue: When it does turn on, it will run, but if I try to resize the window it crashes.

If you know any way to fix this, please help. Thanks.

Tried (unsuccessfully): disabling microsoft defender, opening from cmd with octave --force-gui

Solution: Deleted configuration and history files, they were in %userprofile%\AppData\Roaming\octave in my case.

3 Comments
2022/09/04
18:53 UTC

2

How to find x value for a corresponding y value from a graph

Hi I am new to octave. I have set of data points and I plotted its graph. My objective is to find the x value for a corresponding y value which is not in the data set. How do I do that in octave?

2 Comments
2022/08/25
02:47 UTC

1

Octave freezes in PopOS (Linux flavor)

Has any one else had issues running Octave on PopOS? I have never had any issues running Octave in Ubuntu linux, but I am having issues with it freezing in PopOS. I posted a question about it here:

https://www.reddit.com/r/pop_os/comments/wh36qi/pop_os_freezes_with_octave/

0 Comments
2022/08/06
05:06 UTC

1

How can I reuse the last result in a new equation?

Simple example:

>> 2 + 3

5

>> (ans) * 2

10

But it's not "(ans)", what is it?

2 Comments
2022/07/31
03:13 UTC

2

Octave-Based State Space Algorithm

As I'm sure many of you know, Octave is great at performing a large number of computations quickly. In particular, you can find the zeros of a 3-dimensional function by simply evaluating a function z = f(x,y) over a large number of points, and using find(z == 0).

However, this does not work for dimensions above 3, since you cannot (to my knowledge) generate all possible domain combinations as easily, which in the case of a 3-dimensional function can be accomplished using the transpose operator:

E.g., z = x + x' is equivalent to evaluating z = x + y over all possible combinations of domain values.

This lead me to work on higher-dimensional cases analogously, ultimately leading to a state-space algorithm that compresses the number of domain combinations, but apparently still leaves enough information to produce exact answers, even when the state-space contains literally billions of possibilities.

I'm sure this can be implemented in other languages, but I doubt it would be as efficient.

Code and explainer:

https://www.researchgate.net/publication/362364602_Universal_Optimization

Charles

0 Comments
2022/07/30
18:39 UTC

2

cannot figure out this, even from last time

I need to set my directory. and, reasonably sure that because a folder contains a apostrophe, octave is giving me a syntax error.

i'm trying to use addpath() to add the path,

then changing directory using cd()

(jsut so I don't ahave to click on the button that asks "would yo like to add directory to load path"

running either one is when I get the syntax error. i've noticed too that double quotes won't work, single quotes do. its been a while since using octave, and am forgetting some of the small formatting syntaxy things.

lastly, the path was copied directly from the function currentfolder=pwd, idk if that is like python, hwere I had to add an r to convert a directory path to "real string", then is there a similar work around here?

anyway. here is the code:

cd('C:\Users\deana\OneDrive\Marlon's files\Octave\Asset Library\Texture Assignments')

returns: (except that little carrot is directly below the "s" after the apostrophe

ꆺerror: parse error near line 12 of file C:\Users\deana\OneDrive\Marlon's files\Octave\Asset Librar

y\Texture Assignments\texture_family_list.m

syntax error

>>> cd('C:\Users\deana\OneDrive\Marlon's files\Octave\Asset Library\Texture Assignments')

^

>>

5 Comments
2022/07/20
01:56 UTC

10

Octave-Based A.I.

I thought I'd share a long-term project I've put together in Octave (the GUI is in Swift), it's AutoML software, and as far as I know, it's literally the fastest on the market, by an enormous margin.

I spent a long time on the theory, but it wouldn't be possible without Octave's incredibly efficient use of CPUs / Memory.

There's a totally Free Version that you can download from the website:

www.blacktreeautoml.com

I'd definitely be interesting in connecting with other Octave developers, so feel free to send me an email (address is on the site).

Best,

Charles

0 Comments
2022/07/18
18:49 UTC

7

How can i fix the white octave screen?

Every time i try to plot some fonction or when i use the command line "imagesc" I get a white screen (figure) where the results suppose to be.

4 Comments
2022/07/11
12:27 UTC

2

How to use this function in the "control" package?

There's a function (implemented) in the control package called @lti/series. For my life I can't find how to use it; series() is not recognized by Octave. Thanks.

4 Comments
2022/06/09
17:07 UTC

3

Benchmark Suggestions

I want to benchmark raw CPU speed (and compatibility) using octave and wanted some suggestions on some simple codes I could use to test each attribute of a CPU. Am I able to create a Multi-Core script on octave? Is there a function that uses the whole CPU? Any suggestion is welcome!

1 Comment
2022/06/01
01:27 UTC

3

How do I change default toolkit in octave?

I'd like to change the default toolkit in octave 7.1. Every time I want to plot any function I always get a white screen , I recently found out that

graphics_toolkit("fltk") Solves this problem for me but I want this command to execute at octave startup.

0 Comments
2022/05/29
03:39 UTC

2

Octave Issue on MacOS

Hello, everyone! I have recently bought a MacBook Air M1 and I installed Octave on it. The problem is that everytime I try opening a ".m" file from the Finder, it does nothing.

If I try to open it from Octave, it works fine. What can I do to fix this issue? It's quite annoying. Sorry if it's a silly question, it's my first time using MacOS.

21 Comments
2022/05/21
23:09 UTC

4

Latex Font in Octave

Hello everyone,

I love Octave as a free alternative to MATLAB. However, I would like to use Latex font in Octave figures if possible. Does anyone have an advice?

Edit: I mean true Latex with syntax and packages.

2 Comments
2022/05/16
20:26 UTC

2

Octave won't install control

Hi, I'm trying to install the control Octave package but I get the following message:

octave:1> pkg install -forge control
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -loctinterp: No such fileor directory
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -loctave: No such file ordirectory
collect2: error: ld returned 1 exit status
make: *** [Makefile:69: __control_helper_functions__.oct] Error 1
make: *** Waiting for unfinished jobs....
make: Entering directory '/tmp/oct-4uV6WR/control-3.4.0/src'
tar -xzf slicot.tar.gz
/usr/bin/mkoctfile-6.4.0 -Wall -Wno-deprecated-declarations  __control_helper_functions__.cc
mkdir sltmp
mv slicot/src/*.f ./sltmp
mv slicot/src_aux/*.f ./sltmp
if [ "1" = "1" ]; then \
   echo "copy routines using DGGES"; \
   cp SB04OD.fortran ./sltmp/SB04OD.f; \
   cp SG03AD.fortran ./sltmp/SG03AD.f; \
   cp SG03BD.fortran ./sltmp/SG03BD.f; \
fi;
copy routines using DGGES
cp AB08NX.fortran ./sltmp/AB08NX.f
cp AG08BY.fortran ./sltmp/AG08BY.f
cp SB01BY.fortran ./sltmp/SB01BY.f
cp SB01FY.fortran ./sltmp/SB01FY.f
cp SB06ND.fortran ./sltmp/SB06ND.f
cp TB01MD.fortran ./sltmp/TB01MD.f
cp TB01ND.fortran ./sltmp/TB01ND.f
cp TB01ZD.fortran ./sltmp/TB01ZD.f
cp TG04BX.fortran ./sltmp/TG04BX.f
cp ODLTZM.fortran ./sltmp/ODLTZM.f
cp makefile.slicot ./sltmp/makefile
cd sltmp; /usr/bin/mkoctfile-6.4.0 -w -c MA02ID.f; rm MA02ID.f; /usr/bin/mkoctfile-6.4.0 -c *.f;
x86_64-pc-linux-gnu-ar -rc slicotlibrary.a ./sltmp/*.o
rm -rf sltmp slicot
make: Leaving directory '/tmp/oct-4uV6WR/control-3.4.0/src'

error: pkg: error running 'make' for the control package.
error: called from
    configure_make at line 110 column 9
    install at line 195 column 7
    pkg at line 568 column 9 

Do somebody know a solution?

4 Comments
2022/05/13
00:18 UTC

7

Using the serial communication in the latest "instrument-control" toolbox.

I'm working with serial communication from a Windows PC and I've been using the more recent function to open the serial port:

serialhandle = serialport('com5')

but there is no documented way to close the serial port.

With the deprecated function you would do this:

serialhandle = serial('com5')
fclose(serialhandle)

Does anyone know how to close the serial port using the latest function? Here's the reference: https://octave.sourceforge.io/instrument-control/overview.html

0 Comments
2022/05/04
20:50 UTC

3

Function works perfectly when given single input, but not when given vector input (likely issue in the if statement)

EDIT: SOLVED

The code:

function h = height (x, a)
    if (x <= -r./tan(a) - l*P)
        h = -r;
    elseif (x >= r./tan(a) - l*P)
        h = r;
    else
        h = tan(a) .* (x + l*P);
    endif
endfunction

Works as expected when x and a are single numbers, but when I try passing vectors, I get out-of-bound results (below/above r), so I expect the problem is with the if statement.

Example of vectors given:

l=5
x=linspace(-l,l,100)
a=linspace(pi/10,pi/10,length(x))

Thanks for any help!

3 Comments
2022/05/03
18:57 UTC

2

Problem with statistics package

Hello everyone,

I've come across some problems when trying to install statistics package for octave, I've tried to install it manually downloading package file and via command but without any success, after that I tried installing make for windows (I followed some youtube tutorial, maybe I did something wrong) hoping it will solve my problem but it also did not help. Maybe somebody here will know what to do. I've installed io package.

PS. Sorry for my English - not native speaker, if something I've written is unclear I will try to clarify in comments.

3 Comments
2022/04/27
10:35 UTC

3

Random Walk Dataset

2 Comments
2022/04/23
01:05 UTC

Back To Top