Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
2
votes
1answer
343 views

ode45 usage in this case?

The background is that I'm solving a problem in numerical analysis and I seem to be halfway having solved the non-linear system and now getting to the part where I should apply solving differential ...
4
votes
1answer
6k views

Machine epsilon (eps)

The wiki for machine epsilon says: "Machine epsilon gives an upper bound on the relative error due to rounding in floating point arithmetic" If machine epsilon is the upper bound on the relative ...
5
votes
2answers
2k views

Integration of matrix-valued function using MATLAB

I need to compute the integral $\int_{\mathbb{R}^3}f(x)\, dx$, where $f$ is a matrix-valued function $f:\mathbb{R}^3\to\mathbb{R}^{3\times 3}$. How do I do that using MATLAB? The function $f$ is ...
1
vote
1answer
3k views

Autocorrelation problems

I have written some code, to produce some data. In what I have shown below, the output is just one-dimensional array of numbers. I have an analytical expression for what the autocorrelation function ...
6
votes
2answers
1k views

matlab eigs: wrong eigenvalues for tridiagonal matrix

I try to compute eigenvalues of the tridiagonal matrix coming from finite difference scheme. For small mesh size, eigs works well. But for large size it fails. Here is an example where eigs fails. Is ...
1
vote
1answer
508 views

matlab find element with diff equals to zero

I have X as a 616 x 1 double. I calculated the differences between adjacent elements of X by using: Y=diff(X); and get Y as a 615 x 1 double, containing positive ...
3
votes
3answers
7k views

MATLAB Subscript indices must either be real positive integers or logicals

I have a n x 3 double containing x, y and z coordinates. Can someone tell me where did I go wrong? store_y_temp=real(Y(Y>Iy)); store_z_temp=Z(store_y_temp); ...
7
votes
2answers
2k views

How do I solve a boundary value ODE in MATLAB?

Specifically, ode15i. I have ode15i solving a system of 5 first order implicit odes in 5 variables with an initial condition (made consistent by decic). It's great for what I need, except I need to ...
3
votes
1answer
3k views

Export mesh and solution from pdetool

I need to run the pdetool analysis several times for different values of pde coefficients. Repeating this procedure for different meshes is not convenient using the pdetool GUI. Is there a way to ...
0
votes
1answer
108 views

Can I use the Matlab Parallel Computing Toolbox with 64 bit linux (using Matlab R2012b)? [closed]

Sorry for the noob question. I'm using Matlab version R2012b on a computer that's running 64 bit Linux. It seems that no version of Matlab's parallel computing toolbox will work for me. Can anyone ...
1
vote
1answer
2k views

How can I get Octave to correctly compute a double integral of a piecewise function?

Computational Science People: The title is the question. I am trying to numerically compute a certain integral over a square in Octave (an open-source Matlab clone). I'm getting the wrong answer. ...
2
votes
1answer
922 views

export pde solution to non-uniform grid

After exporting the solution (u) and the mesh (p, e, t) from pdetool to workspace, I need to compute the solution at a set of predefined points. These predefined points where the solution is sought ...
1
vote
0answers
2k views

Simulink PDE (MATLAB)

I need to build a system in Simulink that solves a PDE, but I can't find any literature or books where it is described how to do it (especially any stuff according to modeling PDE in Simulink). ...
5
votes
1answer
967 views

Code to numerically integrate a system of first-order ODEs

I need to solve the following system of differential equations. When I have the solutions for $n_f$ and $v$, I need to find and plot $J=-e_\cdot n_{f} \cdot v$. I wrote a code in matlab with all ...
1
vote
3answers
3k views

Matlab output in scientific notation [ERROR: Subscript indices must either be real positive integers or logicals.]

I have X, Y and Z variables in matrix form, each of size n x 1. Eg.: X = [-38.0400, -38.6700, -38.9300, -39.4500...] Whenever I run the code below: ...
2
votes
3answers
1k views

Introductory tutorial for Monte Carlo computations on the GPU?

Monte Carlo simulations for MATLAB sometimes require a huge usage of CPU and in some cases may take a long time. MATLAB has provided some structures in order to enable the parallel processing. But I ...
3
votes
2answers
335 views

Nanoseconds vs. picoseconds in numerical quantum problems with Matlab ODEs

Hello there and thanks for taking a look at this problem. This problem is related to my previous question and I will therefore use a similar introduction from, Choice of step size using ODEs in ...
0
votes
1answer
448 views

Convert hour of the year into date in Matlab [closed]

I am a new Matlab user and wondering if there is any built-in operator or function which could convert the hour of the year into calendar date and time for that year. For example, Hour 0 in year ...
2
votes
1answer
172 views

How to solve this numerical technique problem?

Well, in a numerical technique test we were given the following problem: A physical phenomenon is modeled such that, $F(f,d) = A(f)/d^2 + L$; Where, $F$ is a function of frequency $f$ and distance $...
8
votes
1answer
184 views

How to recreate this result (from a book)?

The result I'm interested in is found within "Synchronization: A Universal Concept in Nonlinear Sciences" page $333$ figure $14.3$. The peculiar fragment is also provided at the end of this post. So ...
3
votes
2answers
4k views

Octave 3D mesh, data from file

I have a big file with 3 columns: density, dimension, value. example: 10 0.3 200 10 0.4 300 20 0.3 250 20 0.4 320 ... I am trying to draw a 3d plot - ...
6
votes
1answer
417 views

Calculate large and small frequency separation for the Sun

I want to determine the big and small frequency seperation from timeseries data for the sun. An excerpt of the data (timeseries and power series) is plotted below. The power series is calculated in ...
12
votes
3answers
4k views

Choice of step size using ODEs in matlab

Hey there and thanks for giving time to look at my question. This is a updated version of my question which I posted earlier in physics.stackexchange.com I'm currently studying a 2D exciton spinor ...
3
votes
3answers
8k views

What is the Complexity of MATLAB operations

I'm trying to analyze the complexity of MATLAB code I wrote. I'm trying to figure out how much (in terms of $O$ or $\Theta$) to give functions like find, matrix <...
5
votes
1answer
1k views

Integration of an indefinite integral: matlab precision problem

The integral I need to evaluate is: $$ \int_x^{\infty} \frac{t^n}{e^{t} -1} dt $$ After some research I found a paper saying, The numerical values of the two integrals [...] are easily calculated ...
5
votes
1answer
143 views

Matlab help related with the scaled Newton's iteration method

I need a little help with Matlab code for the method mentioned in this paper for computing the inverse of the matrix. In this paper, the author presented scaled Newton iteration given by $X_{k+1} = \...
2
votes
1answer
128 views

How to save a matlab source code into a string in matlab?

I want to save a matlab source code into a string format in matlab. Does anyone know how to do this? For example, type xxx.m can display the source code of xxx.m. ...
1
vote
1answer
941 views

How can I compute whether a sequence is an even or odd permutation of an increasing sequence? [closed]

Variants of this question have been crossposted to Stack Overflow and Mathematics Stack Exchange. Additional answers may be found at these other sites. Computational Science People: I originally ...
5
votes
1answer
7k views

Implementing Explicit formulation of 1D wave equation in Matlab

So the theory is straightforward. We have: $$\frac{\partial^2U}{\partial t^2}=c^2 \frac{\partial^2U}{\partial x^2}$$ discretizing it gives: $$\frac{U(i+1,j)- 2U(i,j) + U(i-1,j)}{(\Delta t)^2} = c^2 \...
2
votes
1answer
2k views

Discrete 3D convolution of matrix valued functions

As stated in the title, I need to make a discrete 3D convolution of two matrix-valued functions. Or, actually, I need to convolve a matrix-valued function with a vector-valued function. That is, I ...
1
vote
2answers
198 views

Solving a "generalized" linear programming problem

I need to solve the follwing constrained optimization problem. Is there any MATLAB toolbox which can solve this. minimize $A_1 x$ subject to $A_2 x = 0$ $A_1$ is an $m\times n$ matrix where $m \...
7
votes
2answers
234 views

Caching mechanism

I've been having problems designing an effective caching mechanism. The mechanism is to be used as part of a project developing scientific software. The goal is to save computation time by loading ...
1
vote
1answer
3k views

matlab set center of output figure to [0 0 0]

I have a few set of data of three dimensional matrices, n x 3 with x, y and z coordinates. I viewed the matrices in the figure window. ...
2
votes
2answers
4k views

Matlab element within ranges and distance between two points

I have a $53534\times 3$ matrix with $x$, $y$, and $z$ coordinates. I want to find the element of matrix within ranges as follows: ...
3
votes
1answer
725 views

How to do local FFT on huge 3D vector data cell mesh and visualize it spatially?

Simulation type: I'm running a simulation with the OOMMF micromagnetics package http://math.nist.gov/oommf/ where are magnet is represented by a mesh of 3 million cells, it gets excited by a ...
9
votes
1answer
7k views

How to approximate the condition number of a large matrix?

How do I approximate the condition number of a large matrix $G$, if $G$ is a combination of Fourier transforms $F$ (non-uniform or uniform), finite differences $R$, and diagonal matrices $S$? The ...
3
votes
2answers
1k views

Finding A and X such that AX = 0, X is positive non-zero, and A is sparse

I apologize if this is a naive question. I'm trying to create some boostrap data for a system of linear, ordinary differential equations at steady state. Since the equations represent the ...
1
vote
0answers
224 views

Sign or cardinality constraint when solving for sparse signal

I'm currently learning about using linear and semidefinite programming to find sparse solutions to problems. In particular, finding sparse solutions where the sampling functions are sinusoidal (...
10
votes
4answers
16k views

Matlab : Is there a way to programatically safely halt code execution (like FORTRAN's stop)? [closed]

Like the title says, I want to be able to stop the code at a specific location and have it halt safely. I cannot find a command to do it like for example in FORTRAN there is the stop command.
1
vote
1answer
1k views

GMRES Matlab 'tol' parameter

I need to use GMRES solver in MATLAB, and I need to play around with the codes parameters and I had a very simple question about its usage. The documentation of the solver here mentions a parameter <...
1
vote
0answers
364 views

features recognition & reconstruction of 3d mesh delaunay matlab

I managed to display the coordinates of x,y and z into a 3D mesh by using delaunay function. The coordinates are in .obj format actually and i have read it into matrix form. Now, i would like to ...
10
votes
1answer
17k views

in matlab, what differences are between linsolve and mldivide?

in matlab, both linsolve and mldivide are used for solving a system of linear equations, in all of determined, overdetermined and underdetermined cases. Reading their documents, I was wondering what ...
2
votes
1answer
511 views

Trying to implement a simple/efficient combinations function in MATLAB

So, recently, I have found myself in the position of having to implement a combinations function in MATLAB. What I mean by this is the following: I simply need to list all possible combinations for an ...
4
votes
2answers
3k views

Testing 1D Poisson Solver

I'm trying to test a simple 1D Poisson solver to show that a finite difference method converges with $\mathcal{O}(h^2)$ and that using a deferred correction for the input function yields a convergence ...
4
votes
1answer
2k views

Implementing the $\theta$-method for solving an IVP

I also posted this question on the Math SE site, but it was suggested I post here also. I want to implement the $\theta$-method to solve an IVP in MATLAB. The $\theta$-method is: $y_{j+1} = y_j + h[\...
8
votes
5answers
4k views

Minimizing $\mathrm{trace}(S)+\mathrm{trace}(S^{-2})$ using CVX

In Matlab, I would like to minimize the function $$f(S)=\mathrm{trace}(S)+\mathrm{trace}(S^{-2})$$ where $S \in \mathcal{M}_{m,m}$ is symmetric and positive definite, which is definitely a convex ...
1
vote
1answer
599 views

How easy is it to combine symbolic and numeric computation in Matlab?

CS Beta people: I have been doing some multiple integrals with a combination of symbolic and numerical integration (because symbolic answers have not always been possible). I have been using ...
7
votes
2answers
194 views

Left and right eigenspaces of the product of Gramians

I solve the Lyapunov equations : $$ A W_C E^T + E W_C A^T + B B^T = 0 $$ $$ A^T W_O E^T + E W_O A + C^T C = 0 $$ to obtain $ W_C $ and $W_O$. My aim is to get the left and right eigenspaces of $W_C ...
15
votes
1answer
1k views

can I trust this numerical triple integral from Matlab?

Computational Science people: I originally posted this question at Math Stack Exchange and someone commented that I might get "much better" answers here: I am a novice at numerical methods and ...
4
votes
2answers
6k views

setting a condition on MATLAB ode45 output

I want to solve a system of differential equations using ode45 , for (many) parameters in MATLAB to investigate the behavior of solutions with coefficients of the equation .I want to find the ...