Questions about the numerical programming language MATLAB.

learn more… | top users | synonyms

1
vote
1answer
31 views

Creating Periodic Noise in Matlab and then adding it to a signal

I am not sure if this is the correct forum for this question but here it goes. If this is not the correct forum please direct me to the appropriate forum. I wish to add some periodic noise to a 1-D ...
1
vote
0answers
47 views

Solving condensate density problem in MATLAB

I want to solve for $n_{0}$ for a fixed value of $n$, lets say $n=1$ $$ n= n_{0}+ \dfrac{1}{2}\int_{-1/2}^{1/2}dq\left(\dfrac{e_{q}+Un_{0}}{\hbar\omega}-1\right) $$ where $e_{q}=2[1-cos(2\pi q)] $ ...
0
votes
0answers
47 views

Matlab to Matplotlib [closed]

I would like to convert 2 snippets of Matlab code to Python/Matplotlib. Here is the first snippet. ...
0
votes
0answers
12 views

Forcing variables to take specific values in ode15s [duplicate]

I am solving a system of ODE's. Instead of using M * dC/dt = F(C,t), I would like to specify the jacobian and instead use M * dC/dt = J * C. Since the problem has Dirichlet type boundary condition, i ...
2
votes
1answer
64 views

Effect of banded matrix on error

It is necessary for me to solve a Poisson problem with a numerical method on a square domain with two types of triangular mesh: uniform triangular mesh (using uniform distribution nodes on square) and ...
0
votes
0answers
111 views

What does this Matlab error message mean?

I'm trying to solve a rather difficult homework project in numerical analysis. Page 16 in the document. Now I have my calculations but as I'm trying to "follow the ray for 25 nautical miles" then I ...
0
votes
1answer
21 views

Interpolating 3D Array non-monotonic data in MatLab

I am working on creating a program for simulations where three variables are parametrized, and we modify one parameter while keeping the other two constant. An example array looks like this when ...
-1
votes
1answer
58 views

Dirichlet boundary condition

I am trying to solve ODEs in matlab using ode15s. Instead of specifying ODEs in the format M * dC/dt = f(C,t) where C is a function of x and t. I want ...
0
votes
1answer
37 views

For loops in matlab with a specific starting point

I have the following definitions long = 1000; init = 500; N = init+long; T = init+1:N-1; T1 = init+2:N; I then fill the vectors ...
0
votes
1answer
58 views

Raising elementwise a large symmetric, positive definite matrix to a power in Matlab

I have created a large positive definite (thus symmetric) matrix in Matlab. For sake of simplicity, let's assume that the matrix has the following form: $K= \left[ \begin{array}{ccc} k_{11} & ...
2
votes
1answer
45 views

find the exact solution ref The finite element method using matlab by Kwon and Bang [closed]

The results found are as under how do we find the exact solution ref The finite element method using matlab by Kwon and Bang.Page no 280-281 Example no 8.10.1.
2
votes
0answers
35 views

Bracket Algebra, Straightening Algorithm

My apologies if the question is simple. I need to write a code for straightening algorithm. Which includes defining bracket algebra. I tried to write it in CoCoA-5, but it wasn't possible because ...
0
votes
0answers
61 views

3D animation of a vector field (ParaView)

I am trying to create an animation of a 3d vector field in ParaView. All my data is in three matrices (201 x 201 x 201) corresponding to vectors components in x,y,z directions. And it's calculated in ...
4
votes
0answers
92 views

Is there a faster method to compute the geometric series of a matrix?

I want to calculate the geometric series of a matrix $A$: $$S=I+A+A^2+\dots+A^n$$ and then apply to a vector $v$, $Sv$. I've done it in Matlab with a loop and I think it's quite efficient applying ...
0
votes
0answers
31 views

How to speed up calls to integral2 in matlab

I am performing a 2D integral for each time step of a calculation. The problem is that I need to vary through all possible permutations of a1,a2 (which always ...
3
votes
1answer
56 views

Simple way to derive transpose of a vectorized operation

In a program I'm writing, I have a sub-routine that does some vectorized linear operations (specifically differentiation). Say for convenience I have defined the following inline function, which ...
0
votes
3answers
101 views

Solving a double integral in Matlab

I need to solve this integral: $M = \rho h \int_0^a \int_0^b N^2 \ dx dy$ where $N$ is defined as: $N = sin\left(\dfrac{\pi}{4}\eta +\dfrac{3\pi}{4}\right)sin\left(\dfrac{\pi}{4}\eta ...
0
votes
0answers
44 views

Calculating Conditional Expectations

I would like to compute the conditional expectation of a particular function : $E_{t}\left[ R(A_{t+1}, \eta_{t+1})\right | A_t]$ where $A_{t+1}$ and $\eta_{t+1}$ are two rv correlated to each ...
1
vote
0answers
86 views

eigs routine in octave

I am using octave and observed a problem with the eigs-routine for non symmetric matrices. Using GNU octave version 3.8.1 the code below gives significant difference of eigenvalues although same ...
0
votes
0answers
39 views

How to compute convergence rate for FVM in matlab?

I have implemented a finite volume scheme using Lax-Friedrichs flux and using Roe's linearization. I want to compute the order of convergence vs. the space-step $h$. I have computed a solution with a ...
0
votes
1answer
89 views
3
votes
2answers
168 views

Projecting Finite Element solution onto new mesh

I am implementing a finite element solver in MATLAB and I have the following problem. Let's say I have a mesh $\mathcal{T}_1$ with triangular elements on a rectangular domain ...
3
votes
2answers
73 views

Bessel EVP and fzero

I am trying to solve the Eigenvalue problem $$ x^2 y''+ x y' + x^2 y = \lambda^2 y\,,\quad x\in(0,1)\,,\quad y(0)=0\,,\quad y'(1)=y(1) $$ The differential equation is the Bessel equation. The solution ...
0
votes
1answer
73 views

Importing results of FEM analysis into Matlab

I need to import in Matlab the results (like time histories of diplacement or frequency response at a specific point) obtained from a FEM analysis in Nastran. At the moment I ask Nastran to save the ...
0
votes
1answer
102 views

Solve poisson equation with Neumann b.c. (matlab or octave)

I'm trying to reconstruct an image given its Laplacian, which results in a Poisson equation and I'm using Neumann boundary conditions (derivative at boundary = 0). What I have is the laplacian (f, ...
3
votes
2answers
286 views

Solution blows up when using Runge-Kutta to solve simultaneous ODEs for liquid film equations

This is a continuation of a problem I asked over at physics exchange and math exchange. Basically I have two ODEs that I am solving in order to calculate the radial and tangential velocity of liquid ...
1
vote
1answer
86 views

Approximate $h$ in $F(\theta)=\sin \theta \int_{-L}^{+L}h(z)e^{-ikz\cos \theta} \,dz$

Consider $$F(\theta)=\sin \theta \int_{-L}^{+L}h(z)e^{-ikz\cos \theta} \,dz$$ $$|z|\le L$$ $$0 \le \theta \le \pi$$ By having knowledge of $F(\theta)$, how can one approximate $h(z)$? In addition, I ...
0
votes
3answers
76 views

Meshing of polygons

I need to generate a sequence of increasingly denser high-quality triangular meshes for some pentagons in MATLAB. I want to supply as my input The coordinates of the 5 vertices of the pentagon ...
0
votes
1answer
103 views

All roots of equation in matlab

I have a equation and I want to find all its roots in matlab but I cant I tried in matlab but it gave me just one of the roots F=(cos(7*x)).*exp(-2*x.^2).(1-2(x.^2)) thanks
5
votes
0answers
58 views

Find the solution of linear equation using Wiedemann/ Krylov method

Let given $M =$ 1 0 1 0 1 1 1 1 1 and $b =$ 1 0 1 How to find the solution $x_3$ where ...
1
vote
2answers
114 views

Determine unit outward normal vector for a curve

It is necessary for me to find the unit outward normal vector for the curve: $$\gamma=(x(t),y(t)) $$ where $$x(t)=\cos(t)−0.5\cos(3t)$$ and $$y(t)=\sin(t)+\sin(7t)+\sin(3t)$$ I know how to find ...
1
vote
1answer
146 views

How to construct the matrix like this

"We consider an unstructured planar (undirected) graph and calculate the stationary probability distribution of the random walk on the graph. The graph is generated by choosing n random points in the ...
1
vote
3answers
138 views

Searching solution for solving huge linear system in MATLAB or C

I am encountering a problem that my MATLAB code ran and an error occurs and shows that it is out of memory. My code is using finite element method to solve some complicated kind of integral equation ...
0
votes
0answers
67 views

Phase retrieval via SDP (semidefinite program) of 2D test image (Matrix completion)

In SDP based phase retrieval we have intensity measurement (abs(FFT2(x))^2) of the form A(xo) = |ak,x|^2 =b^2, phase retrieval is then find x that obeys A(xo)=b The quadratic measurements can be ...
1
vote
0answers
54 views

ARPACK gives different answers from Matlab and NAG

I'm playing with ARPACK. I looked into the examples they provide, zndrv4.f illustrating the usage of the routine znaupd, in the directory of ARPACK/EXAMPLES/COMPLEX/. I also came cross NAG Fortran ...
0
votes
0answers
73 views

Eigen vector property: MATLAB 'chol' (LAPACK DSYGV) & MATLAB 'qz' (LAPACK DGGEVX)

Two Eigen algorithms return Eigen vectors with different properties: 1st algorithm, LAPACK DSYGV (the same as MATLAB eig with ...
0
votes
0answers
33 views

Numerically boosting between reference frames

I have a question about numerically boosting between reference frames in MATLAB. Simply stated, if I have a function $f(x,t)$, I want to write it in a new frame, ...
0
votes
1answer
65 views

What is the best method to combine multiple vectored results into one chart?

Currently I am working on my research report where I've done a lot of measurements. For now I have uploaded everything into Matlab and visualise each on chart. Each one consists of 4 lines drawn with ...
0
votes
0answers
66 views

how to pick a submatrix of a sparse matrix quickly(matlab)

I have a large sparse matrix A and i want to pick the submatrix of it to do block jacobi iterations. For the blocks, i have get a matrix Q that contains the index of nonzero entries in its Jth column ...
1
vote
1answer
73 views

Switch between 2 equations to be given to ODE using events

I am trying to simulate a system with bilinear stiffness described by the following equations: $25\ddot{x}+15\dot{x}+330000x = p(t)$ if $x < 0.00072$ $25\ddot{x}+15\dot{x}+930000x = p(t)$ if $x ...
0
votes
1answer
60 views

Help me analyze the computational cost of two kinds of operations

everyone, I have a question about computational costs for a algorithm. That is: I have two vectors $u_n,\ v_n\in \mathbb{C}^N$, a matrix $A\in \mathbb{C}^{N\times N}$ (can be both sparse and dense) ...
1
vote
0answers
130 views

How to solve an ode with stochastic time-dependent input

I am trying to repeat an example I found in a paper. I have to solve this ODE: $25 \ddot{x} + 15 \dot{x} + 330000 x = p(t)$ where $p(t)$ is a white noise sequence band-limited into the 10-25 Hz ...
2
votes
2answers
215 views

Eigenvectors: MATLAB vs LAPACK DGGEV or DGGEVX

If we call LAPACK DGGEV or DGGEVX routines for two badly-conditioned matrices in a C++ code, will we get the same eigen-values ...
5
votes
1answer
100 views

What is a good way to take fractional powers of a matrix in MATLAB?

I am working on a problem that involves taking fractional powers of particular matrices. For the matrix A with 2 on the main diagonal and -1 on the sub and super diagonal (the finite difference ...
3
votes
1answer
197 views

Why is my MATLAB code for back-substitution slower than the backslash operator?

I wrote the code below to invert an upper triangular matrix, avoiding any possible multiplication/subtraction by zero. It just uses $\frac{1}{6}n^3+\ldots$ flops instead of $n^3+\ldots$ flops. ...
1
vote
0answers
78 views

Optimizing rank computation for very large sparse matrices

I have a sparse matrix such as ...
1
vote
1answer
200 views

Nonlinear ODE to solve Duffing's equation

I am trying to solve the Duffing's equation in MATLAB. $ m\ddot{y}+c\dot{y}+ky+k_{3}y^{3} = f(t) $ where $ f(t) = A \sin{\omega t}$ To do that I wrote a function to be given to the ode45. ...
0
votes
1answer
52 views

Why doesn't the integral of a smoothing kernel equal 1?

I was checking the unity condition on a smoothing kernel for SPH, however I don't understand why the integral is not giving 1. The kernel function is $\displaystyle W(||\vec r||,h) = \frac{315}{64\pi ...
0
votes
1answer
182 views

2D cross section from 3D surface

I am trying to apply the "restoring force surface" method to a dynamic linear system. The idea behind this method is that, knowing acceleration, displacement, velocity and input force it is possible ...
0
votes
1answer
77 views

Scaling factor of the inverse Fourier Transform (for convolution purposes)

I have a certain 2-D function. More properly, I have not the function itself, but the matrices $[X,Y,Z]$, where $X,Y$ are $1\times n$, and $Z$ is $n \times n$. Now, I want to calculate a a new ...