Hot answers tagged

8 votes
Accepted

Computational time not proportional to integration interval in ODE-solver?

Substantially edited, since the original poster changed his equation... In general, the MATLAB (and Octave) ODE solvers dynamically adjust the step size as needed to maintain an accurate solution. ...
Brian Borchers's user avatar
6 votes
Accepted

Finite difference method basic implementation on Octave

Summarizing and formulating the answer: (part of it was already given in the comments by user14717, Christian Clason, and Kirill) While performing numerical differentiation using finite differences, ...
Anton Menshov's user avatar
  • 8,652
5 votes
Accepted

Solving constrained odes's using inbuilt solvers in Matlab/Octave

Yes you can. If the term that multiplies $N$ is never zero, then $N$ is an algebraic variable of index 1. Its combination with the ODEs on $x$ yields a system of differentiel-algebraic equations (DAEs)...
Laurent90's user avatar
  • 1,808
4 votes

Alternatives to Comsol Multiphysics

You might also want to have a look at: Elmer https://www.csc.fi/web/elmer Kratos http://www.cimne.com/kratos/ OpenFoam http://www.openfoam.com/ CaeLinux http://caelinux.com/CMS/
Stefan's user avatar
  • 141
4 votes
Accepted

Nice plot of f(x)

Using Python and mpmath: import matplotlib import mpmath f = lambda z: z**3-z+1 mpmath.cplot(f, points=100000) Easy peasy.... See here for the documentation on <...
GertVdE's user avatar
  • 6,179
4 votes
Accepted

BLAS libraries for Octave or Matlab, preferrably with GPU support?

Among open-source BLAS, as far as I know, OpenBLAS (http://www.openblas.net/) is the best option. The website has a DGEMM benchmark, comparing against MKL (see below) and the reference Fortran BLAS. ...
Aditya Kashi's user avatar
3 votes

How can I extract the banded or block diagonal part of a sparse matrix in MATLAB?

(This answer is valid for both MATLAB and Octave, even though I mainly refer to MATLAB) There are two beasts to slay; but let's first understand the underlying data structure. MATLAB and Octave store ...
Abdullah Ali Sivas's user avatar
3 votes
Accepted

Problem with my Octave code (unsteady heat equation with FEM)

Reading quickly through your code, it seems that you never update B. So the term $T^n$ of the previous step remains unchanged, hence you are effectively computing the same step over and over again... ...
Laurent90's user avatar
  • 1,808
3 votes
Accepted

denoting a variable as a matrix using octave syms package

I don't think Octave's syms package supports this kind of matrix algebra operations, but you can do that in Mathematica. EDIT: and also in Sympy.
Federico Poloni's user avatar
3 votes

How to vectorize 2 nested for loop with one complex condition in the inner loop?

Another approach is to use the fact that true is equal to $1$ and false is equal to $0$. If both conditions in the ...
Ertxiem - reinstate Monica's user avatar
3 votes
Accepted

Plot a multi-variable equation in (discontinuous) regions

First, you originally wrote that your equation is $\cos(K)=5 \text{ sinc}(5.12\sqrt{E})- \cos(5.12\sqrt{E})$, but you clearly meant $\cos(K)=5 \text{ sinc}(5.12\sqrt{E}) + \cos(5.12\sqrt{E})$ Second, ...
LedHead's user avatar
  • 1,243
3 votes
Accepted

Matlab struct vector

You can do something like this in Matlab: N = 1e4; c = []; c.x = [0 1]; c(1:N) = c;
spektr's user avatar
  • 4,228
3 votes
Accepted

Plot 2D piecewise constant in matlab in a finite elements mesh

I use typically the following approach. The idea is to make a new mesh where every vertex is duplicated so that each triangle has its own copy. Then you can use standard trisurf command to the ...
knl's user avatar
  • 2,061
3 votes

BLAS libraries for Octave or Matlab, preferrably with GPU support?

MATLAB already comes with Intel MKL for its BLAS implementation. There's no reason to replace that. As for using GPUs, if you make your array a gpuArray (to do ...
Chris Rackauckas's user avatar
3 votes

How do I check if a value my function returns is a multiple of 180?

modulo operation is the cleanest, you could then compare the output of the modulo operator to see if it's less than your threshold for "very close"
user7257's user avatar
  • 414
3 votes

Good IDE for GNU Octave?

QtOctave (source1, source2) among many others like OctaveOnline, Jupyter Notebook, Emacs, Sublime Text, VS Code, etc. support Octave code editing, syntax highlighting, and more. ...
shripal mehta's user avatar
3 votes
Accepted

How can I find the current for a nonlinear electrical circuit using the Shockley equation, in Octave?

The easiest way is to create a lambda function at call time which lets you set "extra" arguments. You can then call this in a for loop and vary the extra argument. ...
helloworld922's user avatar
2 votes

eigs routine in octave

As per the submitted bug report, there was a bug in ARPACK < 3.1.5 regarding dneupd, the subroutine that "returns the ...
Anton Menshov's user avatar
  • 8,652
2 votes

Is it possible to use Octave to learn MATLAB programming?

The best free language which has MATLAB-like syntax is Julia. It's also faster and has a more extensive package system (among other reasons why it's better...), but the linear algebra syntax is almost ...
Chris Rackauckas's user avatar
2 votes

Minimizing vector norm without using symbolic packages

You shouldn't be using symbolic package for this task. Also your usage of ones is going to produce n-by-n matrix of ones - which is not what you intended. Given the ...
Abdullah Ali Sivas's user avatar
2 votes
Accepted

How to vectorize 2 nested for loop with one complex condition in the inner loop?

rmid = 0.5*(r_int + r_ot); rlen = 0.5*(r_ot - r_int); cc = double(abs(circ - rmid) <= rlen);
user7440's user avatar
  • 617
2 votes

Solve discontinuous ODE with lsode

If you speak of discontinuous ODE, one would think of a discontinuous right side function. If the discontinuity is only a jump, and only depends on time, then using the ...
Lutz Lehmann's user avatar
  • 5,974
2 votes

(Lack of) Availability of Finite-Difference library for simple 2D PDEs

I know this is a little bit late, but there's a third party library in Python which solve PDEs using FD, it is called findiff. Check it out.
Heitor Nunes Rosa's user avatar
2 votes

(Lack of) Availability of Finite-Difference library for simple 2D PDEs

It seems hard to write a general enough FD library thas has wide applicability, since FD methods are not as easy to write for general domains, unlike FEM which uses unstructured grids, for which there ...
cfdlab's user avatar
  • 3,028
1 vote

GNU Octave: using 'parallel' with an array (apply function to each array member)

I can not reproduce the error. Here is the snippet I am using: ...
Abdullah Ali Sivas's user avatar
1 vote

Rem function in Octave showing wrong result

$0.1$ is not exactly representable in double precision arithmetic, and it will be rounded. The double precision representation of $0.1$ is $\verb|00111111 10111001 10011001 10011001 10011001 10011001 ...
Abdullah Ali Sivas's user avatar
1 vote
Accepted

Plotting two data sets in Octave

Use plot(x,[y1;y2]) but make sure that y2 is of the same size as y1, because in your example that isn't the case.
Ron's user avatar
  • 725
1 vote

surface: rows (Z) must be the same as length (Y) and columns (Z) must be the same as length (X) in octave

Double-check the documentation of mesh. temp3 must be a matrix of size length(temp1) x ...
Federico Poloni's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible