# Tag Info

35

The Euclidean distance between two vectors is the two-norm of their difference, hence d = norm( x1 - x2 , 2 ); should do the trick in Octave. Note that if the second argument to norm is omitted, the 2-norm is used by default.

12

Not sure if you find the COMSOL Model Wizard somewhere else, maybe other commercial Multi-physics software but not in the open-source community. I had the same question a couple of years ago and I listed all Finite-element, Multi-physics framework. As you may know there are many of them. The one that I found really useful and close, at least in the way that ...

7

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. If the integrator starts to use smaller step sizes then the process slows down. Looking at the particular form of your ODE, the $\sin(wt)$ factor has a ...

4

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 mpmath.cplot

4

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. The library is threaded and written in C and assembly. For GPUs, there's clBLAS (https://github.com/clMathLibraries/clBLAS) that implements BLAS using OpenCL. ...

3

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 that, just do gpuArray(A)), then you can use MATLAB's matrix multiplication and it will use optimized kernals from MAGMA to perform the computation. You can Google around to reason some people ...

3

You can also try distancePoints http://octave.sourceforge.net/geometry/function/distancePoints.html

3

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.

3

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, the $\text{sinc}()$ function has differing conventions. The other question is based on Mathematica, which uses the convention $\text{sinc}(x) \equiv \frac{\sin ... 3 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, one would observe two sources of error: truncation and rounding. Truncation error (for simplicity, what order terms are truncated from the Taylor series ... 3 You can do something like this in Matlab: N = 1e4; c = []; c.x = [0 1]; c(1:N) = c; 3 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/ 3 (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 sparse matrices in the coordinate (COO) format, i.e. a sparse matrix S is a collection of three arrays of the length equal to the number of nonzero entries of S:... 2 Your R1 function should be vector valued (it appears as though it is scalar valued). For example, this appears to work: function out = R1(t) out = t < 1; end dIF = @(x,y) R1(x) .* R1(y); dblquad(dIF, 0, 3, 0, 3) 2 The mesh function plots functions z=f(x,y). So to call the mesh() function, you must have 2D data. You can give vectors for x and y, but z must be an array with length(x) rows and length(y) columns, or x and y and z must be all be 2D arrays of the same size. Your data has been pulled out into a single, long vector which you need to two-dimensionalize. I ... 2 I assume you didn't specify the fprime parameter. If you don't provide this param fmin_cg has to figure out its own solution what usually is much slower than which a provided optimal solution. Your code might look like this: theta = fmin_cg(compute_cost_reg, fprime=compute_gradient_reg, x0=theta, args=(X, y, lambd), maxiter=50) 2 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 exactly the same (many algorithms you can translate to MATLAB by changing A[i] for indexing to A(i)). I believe it's the best language to learn right now, and ... 2 As per the submitted bug report, there was a bug in ARPACK < 3.1.5 regarding dneupd, the subroutine that "returns the converged approximations to eigenvalues". In ARPACK 3.2.0, this particular issue has been resolved. Current distributions of octave are usually linked with a much higher version of ARPACK; thus, such behaviour is not expected to happen ... 2 Another approach is to use the fact that true is equal to$1$and false is equal to$0$. If both conditions in the if statement are met, the result is$1$, otherwise it's$0$. segs = 1000000; r_int = 100; r_ot = 2000; x = linspace (0, 1000, segs); y = linspace (0, -1000, segs); [xx, yy] = meshgrid (x, y); circ = xx.*yy; circ_matrix = ( r_int<=circ ) .* (... 2 rmid = 0.5*(r_int + r_ot); rlen = 0.5*(r_ot - r_int); cc = double(abs(circ - rmid) <= rlen); 2 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 resulting mesh structure. p=coord'; t=ele'; x=p(1,:); y=p(2,:); P=[x(t(:));y(t(:))]; T=reshape(1:size(P,2),[3 size(P,2)/3]); % create random u for testing u=rand(size(... 2 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 same problem, I wouldn't write a new function. I believe fminunc will be more than enough, but of course if this is an assignment you should follow the guidelines given in the assignment. Below ... 2 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 is a standard approach. I know of two libraries which might be useful for you Overture: An Object-Oriented Toolkit for Solving Partial Differential Equations ... 1 You can define the elements of the matrix and then do the rest of the computations as intended. For instance: syms a b c d x = [a b; c d] y = (x' .* x)^(-1) z = y * x Edit: I've found a related post, which I used in the first part of this edit. Another approach is to create a matrix of a determined size: a = sym('a' ,[2 3]) The transpose a' works as ... 1 I found the answer! Octave/MATLAB's function splinefit differs from polyfit in the sense that the polynomial in the former is proposed as:$\sum_{n=0}^k a_n(x-x_o)^n$and in the latter$\sum_{n=0}^k a_n x^n$Where$x_0$refers to the range$[x_0,x_f]\$ of the absissa.

1

Possibly this is what you want? function schrodingerEqn psi0 = [0 1]; hbar = 1; t = [0:1:100]; fh = @(t, psi) f(t, psi, hbar); [T, psi] = ode45(fh, t, psi0); figure; plot(T, real(psi(:,2))); end function dpsi = f(t, psi, hbar) dpsi = 1/(hbar*i)*[1 0;0 1]*cos(t)*psi; end

1

You can do it in maple like this. First you need to specifiy the lower and upper limits. a, b, and c. For normal/primitive integration, we use int(1/x, x = a .. c); Now to find the Cauchy Principal Value, there is built-in option in maple int, int(1/x, x = a .. c, 'CauchyPrincipalValue'); But if you actually want type in yourself then Limit(Int(1/x, x ...

1

In MATLAB I suggest using the pdetool GUI which provides an easier-to-use interface to the assempde function.

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