Questions about the numerical programming language MATLAB.

learn more… | top users | synonyms

0
votes
0answers
16 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
39 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
2answers
67 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 ...
-2
votes
0answers
24 views

how could I find the minimum of computational cost of operation

Let the following statement: $$\phi=p_{xx}A^{-1}B+2p_x(A_x^{-1}B+A^{-1}B_x)+p(A_{xx}^{-1}B+2A_x^{-1}B_x+A^{-1}B_{xx}),$$ where $$A_x^{-1}=-A^{-1}A_xA^{-1}$$ and ...
0
votes
0answers
20 views

How can I run Normal Boundary Intersection (NBI) method with matlab or any other software?

I have a constraint optimization problem. I want to convert it to a multi-objective mathematical programming problem (Multi-objective optimization , vector optimization). I need to run Normal Boundary ...
0
votes
0answers
27 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
75 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
34 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
76 views
3
votes
2answers
153 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
66 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
64 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
58 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
264 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
84 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
73 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
92 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
52 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
79 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
145 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
130 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
53 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
45 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
66 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
61 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
53 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
64 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
58 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
105 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
187 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
93 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
130 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
76 views

Optimizing rank computation for very large sparse matrices

I have a sparse matrix such as ...
1
vote
1answer
132 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
47 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
0answers
119 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
69 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 ...
1
vote
1answer
152 views

What kind of test cases are convenient to use for testing the code for Euler equations of gas dynamics in polar coordinates?

Consider Euler equation of gas dynamics in polar coordinates as $$ \left( \begin{array}{ccc} \rho \\ \rho u_{r} \\ \rho u_{\theta} \\ E \end{array} \right)_{t} + \frac{1}{r} \left( ...
0
votes
0answers
121 views

Piecewise linear approximation of an experimental data curve. Knots position constrained

I need to fit a curve, obtained from experimental data, with a piecewise linear model (4 knots and therefore 3 lines). I tried using the MATLAB function ...
0
votes
2answers
78 views

passing arguments to ode45 with 'flag'

I want to pass additional parameters to the ode45 function in MATLAB. There are many questions already on this, but I also have a 'flag' argument in my function. ...
1
vote
0answers
99 views

MATLAB: incorrect computation with pdepe for parabolic-elliptic system

I have found that MATLAB solves 1D parabolic-elliptic system incorrectly by using pdepe function. Here is a system: $$ u_t = u_{xx} + 2, $$ $$ 0 = v_{xx} + u. $$ Boundary conditions: $$ ...
1
vote
1answer
163 views

How to write a function-generating code in Python/MATLAB?

I want to write a code that generates a function I(t) that satisfies the following condition: $\frac{\big<I(t)^2\big>}{\big<I(t)\big>^2} > 2$ In other words, $\frac{\lim_{T \to ...
2
votes
1answer
59 views

single-variate function variational Intensity Plot for Matlab

I'm wondering if it's possible to create functional intensity plots in matlab. Examples of what I'm looking for are below found in this paper: These figures were (guessing) probably made in R, ...
1
vote
1answer
77 views

Plot a surface from data sets in MATLAB

I tried to plot a surface in MATLAB but, since it is the first time I had to do something like this, I need a confirmation on the process I followed because it is important for my project to plot the ...
3
votes
0answers
269 views

Numerical integration and filtering of acceleration experimental data

I have a vector containing acceleration measurements and the corresponding vector of times in which measurements are taken. To obtain velocity and displacement I used the cumtrapz() function already ...
-4
votes
1answer
62 views

Can anyone give me some suggestions about optimize my Matlab codes?

recently, I try to write a Matlab codes to implement a sparse approximation inverse factorization method proposed by M. Benzi in his paper http://www.mathcs.emory.edu/~benzi/Web_papers/ainv.pdf this ...
2
votes
1answer
105 views

Saving symbolic function to increase efficiency in Matlab

I have a lengthy expression which is calculated using symbolic differentiation of a rather complicated function. I now intend to call this resulting (symbolic function) in a for loop many times, and ...
1
vote
1answer
29 views

Maple stored variable to be read into Matlab

I have a a function $f(k)$ (calculated in Maple) which is huge and stored in a variable called 'sum' on my drive (with the help of 'save' command in Maple). Since the function is huge, Maple is unable ...
1
vote
1answer
90 views

numerical integration of exponential which contains complex function

Hello everyone i'd like to get the result of Fresnel-Kirchhoff integral in paraxial approximation to the cylindrical diffracted wave and here is a part of my code and if it is solved gonna be carried ...