/r/octave
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.
/r/octave
Hello, I am trying to export a bunch of plots with octave and I was wondering if there is a way of easily exporting plots with using the print command, such that they have the same aspect ratio as in the previews that one can see while running the octave script?
Thanks in advance for any help <3
I'm trying to plot phase space diagramm of a 1D harmonic oszillator. I managed to plot the diagram with normalized arrows. Now I want to color code the arrows to emphasize their original magnitude. Does anyone have an idea how I could do that ?
I've had the control package installed for a quite a while but suddenly it stopped working. If anyone can help it would be greatly appreciated.
__control_slicot_functions__.oct: undefined symbol dgegs_error: called from
New user here.
Does octave have a jit compiler? If yes, how to use it on windows?
Also the current version appears to accept "parfor" without any additional packages. So this is standard?
Thank you for your help!
Every time I try to run my code it doesn't work and this error pops up on my command window. I've been using octave for more than a year and this never happened. I've looked it up and even tried AI to try to figure out the reason for this but the advice I gathered wasn't of any help, although I know it as something to do with octave not recognizing the letters. If you could tell how to fix this I would appreciate it very much, thank you.
Hi, I'm writing some Octave programs for a college project and I need to code a function that given a Matrix A, it makes an LU factorization with partial and full pivoting. Right now I have written the code for the Factorization with partial pivoting but I'm not able to make the code for the full pivoting. How could I adapt the code of my partial pivoting function to use full pivoting? Here's the code for the partial pivoting function:
function [L, U, P] = FactLUPC(A)
% Get the size of A
[m, n] = size(A);
% Initialize matrices
L = eye(m);
U = A;
P = eye(m);
for k = 1:min(m, n)
% Find the index of the pivot
[~, max_index] = max(abs(U(k:m, k)));
max_index = max_index + k - 1;
% Swap rows of U and P
if max_index != k
U([k, max_index], :) = U([max_index, k], :);
P([k, max_index], :) = P([max_index, k], :);
if k > 1
L([k, max_index], 1:k-1) = L([max_index, k], 1:k-1);
end
end
% Factorization
for j = k+1:m
L(j, k) = U(j, k) / U(k, k);
U(j, :) = U(j, :) - L(j, k) * U(k, :);
end
end
end
i want to know what is cause of this error in command window
and why is it showing file doesnt exist in terminal
I'm using gnu octave to generate audio. I tried to use the audioplayer function with 4 and 8-track arrays, but it doesn't play the audio on 4 or 8 output channels. Even in 9.2.0 this doesn't work. I cannot find any information about this problem. With mono or stereo arrays everything is fine. If you have experience with this problem, please tell me. I tried it on Mac OSX Ventura, but also on windows11 it doesn't play the four tracks. I have tested the settings of my 8-track audiocard the AUDIO-configuration (on mac) and I can play 4 or 8-track files with quicktime. In the documentation multitrack audio is explicitly mentioned:
Here is my script:
% Define audioproperties
samrat=44100;
bitrat=16;
% Create audio array
t=4; %seconds
tt=(1:(samrat*t))./samrat;
tone1=[sin(2*pi*200*tt) tt*0 tt*0 tt*0];
tone2=[tt*0 sin(2*pi*300*tt) tt*0 tt*0];
tone3=[tt*0 tt*0 sin(2*pi*400*tt) tt*0];
tone4=[tt*0 tt*0 tt*0 sin(2*pi*500*tt)];
toneA=[sin(2*pi*200*tt) tt*0];
toneB=[tt*0 sin(2*pi*400*tt)];
% This one work perfectly
toneout2=[toneA;toneB]';
% This one doesn't work.
toneout4=[tone1;tone2;tone3;tone4]';
% Call player
player = audioplayer (toneout4, samrat, bitrat);
play (player);
If you have an idea how to solve this problem or experience with this function your reactions are highly appreciated.
x=linspace(0,2.5,6)
y=-16*x^2+100
but the command window says error:for x^y,only square matrix arguments are permitted and one argument must be scalar. Use ^for elementwise power.
As an absolute newbie,I think there should be nothing wrong with it from a mathematical expression perspective.
a=-1.5;
b=-1;
f=@(x)sqrt(x+2)-2*cos(x);
tol=1e-3;
n=15;
format long
%Komentar
if f(a)*f(b)>=0
error("Los unos")
end
xTacno=fzero(f,[a,b]);
xMin=-1.6;
xMAx=-0,9;
X=linspace(xMin,xMax,1000);
Y=f(x);
plot(X,Y,'b');
hold on
plot(xTacno,0,'r',MarkerSize',5);
plot(a,0,'b.',MarkerSize',5)
plot(b,0,'b.',MarkerSize',5)
%fplot(f,[a,b])
plot([xMin,xMax],[0,0],'k');
xlim([xMin,xMax]);
grid on
for i=0:n
x=(a+b)/2;
plot(x,0,'y.','MarkerSize',5)
pause(1)
fprintf('%d:x=%.7f/n',i,x);
if abs(f(x))<tol
break
end
if f(a)*f(x)<0
b=x;
else
a=x;
end
xOld=x;
plot(xOld,0,'k','MarkerSIze',5)
end
hold off
Is it just me or is Octave on android wrong?
a few days ago I bought octave in the playstore my phone is an OppoA57 and when I try to open the application tells me error and exits the app, leaving the app insersible and a great feeling of helplessness because I use it for vector analysis classes.
How can I download octave on my compuradora, I try to do it on the official GNU page and it tells me that the connection is expired, nothing is downloaded, the screen appears as if there is no wifi even though there is.
Does anybody know whats going on here? All other tabs work, just the command window displaying spurious characters. Have been running old Octave 5.2 no issues, tried 9, then worked backwards to 6, still get this, but fine on 5? Am running Windows 7 with latest updates (no desire to use windows 10 with forced updates & restarts on a machine dedicated to running modelling & analysis 24/7)
Happy to announce the latest release (1.7.0) of the Statistics package for GNU Octave. See the release notes [here](https://github.com/gnu-octave/statistics/releases/tag/release-1.7.0).
I have written a program that basically does a fork load of math so I don't have to. Right now I am having it display each row of the matrix as it writes it with
disp(data(Row));
Is there a way to get it to display less information. I'd ideally just want
Construction_Angle = x
Construction_Line = y
I'm trying to plot a large red point on a plot using Octave. I can't figure out how to get the dot at the place indicated on the graph. When I try to plot the point it is always in the wrong spot. Can someone help me to be able to plot a solid red dot at any point on this graph? I've included my code below, and image 'IM.jpg'.
soils_triangle='IM.jpg';
hold ("on");
imshow (soils_triangle);
sandmin=65;
sandmax=457;
claymin=412;
claymax=26;
sand=(sandmax);
clay=(claymin);
plot (sand, clay, "ro", "markersize", 12, 'ydir', 'reverse');
hold ("off");
pause(4);
close all
I perform soil analyses, where I get percentages of clay and sand. I want to plot these values overtop of the Canadian Soils Triangle. Can someone please tell me how to do this?
In other words, I'd like to import the image below into a graph, and use the same axes as on the triangle in the image. From this point, I'd like to put a red dot where the values indicate.
Hey, anyone know how can i execute commands like "simpleFoam" in blueCFD for run an openFOAM simulation from octave?
For those of you who are investement sector focused and/ or (more experienced in Octave), how do you guys import stock data/ download web tabular data into GNU Octave? I have tried almost every single codes (including the most popular one Octave:##>>"......fecth_yahoo()....") I have come across without success. I have even tried tinkering with the code by using the "_yahoofinance" tag to try to comply with the new yahoo-finance api change. I am still get error from the interpretor. Recent warning is below:
">> fetchscndattempt error: 'fetch' undefined near line 26, column 12 The 'fetch' function belongs to the financial package from Octave Forge but has not yet been implemented. error: called from fetchscndattempt at line 26 column 10"
F.I.Y.
"pkg describe" confirms that financial pack is loaded.
Hope those of you with more experience can point me in the right direction/ to simple solution to this proble. Thanks in advance.
P/S Just for context, I am still a noob in programming in general and in the Octave/ Matlab Ecosystems. My best experience in programming comes from dabling in vba for excel. Played around a bit with in recent times with Python but its numerous libraries and their own problems gave me choices selection paralysis and other headaches to the point I was losing focus of my project. I dont have alot of free time per day and dont want to look focus of my main objectives and thus recently switched to Octave/ Matlab just for their simplicity (At least, it seemed, until this speed bump).
I've noticed that the movstd function swaps the dimensions of my matrix.
My input is Mdata_rs a 3x5x100 matrix and the output movSTDdata_rs is a 5x100x3 matrix. I tested with a smaller 3D matrices (2x3x5) and it works fine. Did I miss something in the documentation?
Here is my code :
clear; close all; clc;
xlist = 1:5;
ylist = (1:3)*10;
% Making a LUT from x and y : LUT --> nConf | x | y
count = 1;
for kx=1:length(xlist)
for ky=1:length(ylist)
LUT(count,:) = [count xlist(kx) ylist(ky)];
count = count+1;
end
end
% Making the data --> nConf | measurement
% data : 1 x1
% 2 x2
% ...
% 15 x15
% 1 x16
% 2 x17
% ...
Nrounds = 100;
data = zeros(Nrounds*length(LUT),2); % Let's have a multiple rounds/cycles measurements
data(:,2) = rand(length(data),1); % Random measurements
data(1:floor(Nrounds)*length(LUT),1) = repmat(LUT(:,1),[floor(Nrounds) 1]); % Fill the nConf column
% Parameter to compute a noise approximation
wlen = 3; % window length
opt = 0; %see movstd doc
%% Reshaping the data in a 3D matrix with each column in the third axis is a conf with Nrounds layers
Mdata_rs = reshape(data(:,2),[length(ylist) length(xlist) Nrounds]);
movSTDdata_rs = movstd(Mdata_rs,wlen,opt,3);
output1 = median(movSTDdata_rs,3); %Get a noise approximation ignoring the possible base line
It is such good software but the community seems dead. Not much activity relative to how good the software is, but there are always updates and many packages. Maybe users just don't need any help and therefore it's kind of quiet around it, and it just keep ticking by itself? What is the state of Octave?
I have constructed a MWE of what I don't understand
%MWE
flag = 1;
function sub = func1
fig1 = figure('Visible', 'off');
sub = subplot(1,1,1);
contour(magic(10));
end
function func2 (sub, flag)
fig2 = figure;
subplot(1,2,1)
copyobj(sub, fig2);
if flag
subplot(2,2,2)
end
end
sub = func1;
func2(sub, flag);
If I run this script, I get a blank figure--two pairs of axes but no plot. If I instead set the flag to zero, I see a contour plot (which is what I expect and need). Can anyone tell me why?
I am running a simulation that takes a while to complete and generates a contour plot (as a subplot of a larger figure). I then need to iterate many times to add a dot to that plot in a certain location. I could speed this up by a gigantic factor if I didn't need to regenerate the contour plot each time, so I have been trying (for the better part of a day now) to just import a handle to a subplot into another figure as a subplot.
FWIW, I can briefly see the plot I need if I switch to the figure window quickly enough. But it's erased when further subplots are created.
Hi,
I am a neuroscientist that recently joined a new lab. While we have a MATLAB license, we don't have license to any of the toolboxes I usually need (see list below). I thought about asking my lab leader to buy these toolboxes, which would cost about 2000 euros. But then I remembered that Octave is out there and several people have been talking positively about it recently. So I decided to have a look. I know that Octave is fairly compatible with MATLAB but not entirely. I assume that running MATLAB code in Octave might not produce identical results, I can live with that since I plan to code exclusively in Octave. How is the other way around? I tend to publish quite a bit of my code and functions, will Octave code produce exactly the same results in MATLAB or is it still an issue?
Finally, before I make the huge jump and try to transition several years of work to a new language I am wondering if I can find similar libraries to the following MATLAB toolboxes (because if I can't, Octave will probably not work for me):
Bioinformatics Toolbox 2) Curve Fitting Toolbox 3) Deep Learning Toolbox 4) Econometrics Toolbox 5) Image Processing Toolbox 6) Optimization Toolbox 7) Parallel Computing Toolbox 8) Signal Processing Toolbox 9) Statistics and Machine Learning Toolbox 10) Wavelet Toolbox.
I know that the best way is to try and see, but I would hate to spend 2-3 months of coding for a project until I hit a wall and have to migrate back.
I have encountered this problem when trying to install the control package on Octave. Any suggestions?
Since I installed octave, every time I try to open GUI I also get a CMD window. Any suggestions for it to open just GUI interface?
I am trying to convert an .m4a file to csv xy point so I can bring them in to a CAD software like fusion 360 and make it into a spline. I am brand new to Octave but what I saw it seemed like the right software to do it but I can't find anyone showing how to do it.. Any help would be great.
Also if you know a different way of doing this please let me know!
clc;clear;
A=5;
B=2;
C=12;
D=15;
dt=0.02;
t0=0;
yac=A;
tf=6;
it=0;
W=0.5;
yv = A - dt * B + (1/2) * (dt^2) * (-C*A - B*dyac) * (1/A);
for i=t0:dt:tf
yn = ((D*i*sin(3*i) - C*yac)*2 - (dt^2)*(2*A*yv) + (B*dt*yv) + 4*A*yac) * (1 / (2*A + B*dt));
it=it+1
vt(it)=i
vy(it)=yac
yv=yac
yac=yn
end
plot(vt,vy)
yn
You want to create a 4-by-7 array of random numbers. Next your program moves through the array, element by element, and sets any value that is less than 0.2 to 0 and any value that is greater than (or equal to) 0.2 to 1.
Your code looks like this, with one line missing (replaced by ???). What command belongs in that line?
A = rand(4,7);
[M,N] = size(A);
for j = 1:M
????????????????????
if A(j,k) < 0.2
A(j,k) = 0;
else
A(j,k) = 1;
endif
endfor
endfor
Hi,
I recently discovered that the group was unmoderated and became restricted (only approved users could post) for almost 2 years.
I requested to be moderator to get it going again.
I'm working through the queue slowly and I hope those who requested to join in the last two years might still be interested.
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