Questions about the numerical programming language MATLAB.

learn more… | top users | synonyms

-3
votes
0answers
17 views

please help me to convert 2d monte carlo simulation program for grain growth to 3d [closed]

function plotgrainsizedistribution(Tmcs2,nodespool) global L0 lembda K1 n1 global coord global num_of_row y1=num_of_row; tmcs=sum(Tmcs2); %summing the entire tmcs value for the each grain ...
0
votes
1answer
122 views

How to solve the problem without using symbolic computation

I have the following simple nonlinear equations with two unknowns only: $$\left\{ \begin{array}{c} \int_1^2{\dfrac{ e^{{a_1} x+{a_2} x^3}}{1+x^2}} \, dx=1 \\[13pt] \int_1^2{ x^2 e^{{a_1} x+{a_2} ...
0
votes
2answers
24 views

Difference between Data structure objects and cell array objects in matlab

I want to know what are the differences between two data structures in MATLAB: Structure Arrays and Cell Array. In what circumstances we can use each of them?
0
votes
0answers
39 views

Most efficient and practical way to avoid calculating inverse matrix?

So I've heard about the LU decomposition applied to avoiding calculating the inverse of a matrix and how it's so much more efficient than the typical inverse calculating functions in numerical ...
-2
votes
2answers
131 views

$\exp(\ln(x))-x\neq0$?

Analytically, the expression $$\exp(\ln(x))-x \enspace,$$ should give 0. However, in Matlab, it does not. x = linspace(1, 10, 10); exp(log(x)) - x; for $x \in ...
0
votes
0answers
61 views

Need help writing the code for the following optimization

I need to find $X$ for which the following expression is minimized: $$ \min ||Y - F^{-1}(X)||_2 + ||X||_1 $$ where $Y$ is an array (of length approx 44000, an audio sample I will be reading using ...
-1
votes
0answers
31 views

a singular Jacobian encountered error

I have problem to solve this equation. It always give me the same error. I have no idea what is wrong with this. I have chosed smaller values for each parameter but still the same error pop out. Also ...
0
votes
0answers
13 views

How can I simulate a PCM (erythritol) charge and discharge with Matlab?

I need a Matlab code in order to simulate a PCM. I should use 1D explicit heat equation [(d2T / dx2) = (1/a) * (dT / dt)].
5
votes
0answers
75 views

Galerkin FEM error when using even number of elements

Intro: I am developing a Galerkin FEM code in matlab - starting small with a simple 1D ODE. The equation I'm trying to solve is: $$a u_x = cos(x), x \in [0, 2\pi]$$ Which has a known exact solution ...
-1
votes
0answers
45 views

Blow-up from PDE or truncation error? How to know and check?

I have this PDE: $u_{t}= u_{xx}+g(t)\cdot u_{x}^{2}$ that I don't have an exact solution for or know if it blows up. However, by using the pseudospectral I get a blow up, : In general, can I check ...
1
vote
0answers
52 views

Numerically computing Viscous Burger

I am trying to solve the Viscous Burgers equation using the spectral method. $$u_t+uu_x = Du_{xx}$$ where $D$ is a constant (chosen to be zero) and with the initial condition $$u(x,0) = ...
3
votes
1answer
79 views

Numerically computing the advection equation

I am trying to write a program to compute the advection equation. $$u_t +u_x = 0$$ I use the spectral method for the spatial derivative $u_x$ and the leapfrog method for the time derivative $u_t$. ...
1
vote
1answer
59 views

Handling figures built for different parameters in Matlab

I couldn't find a simple answer to this thing I'm trying to do in Matlab. I have a function file that does some calculation for a given parameter a: ...
1
vote
0answers
37 views

Scaling a vector-valued non-linear function for numerical optimization/minimization

I am trying to minimize a non-linear vector-valued function in MATLAB. As a test case for my code, I try to minimize a function whose solution I know apriori. The problem is that one of the ...
1
vote
2answers
43 views

MATLABs double arithmetic

this is a classical problem, but I need help to pinpoint what I am missing. Problem: In MATLAB (exp(1) + 10^12) - 10^12 gives you a double which equal to e, up to 5 correct digits. But I thought ...
0
votes
0answers
115 views

Two stage rocket launch using Runge-Kutta 4 gives weird results

I want to see how much fuel it takes to send a rocket into space. By changing the initial fuel, after I pass 2150 tones, the speed vy becomes negative. Even by ...
0
votes
0answers
73 views

How to solve a set of 1st order 1D PDEs in Matlab?

i have already asked something similar to this once but sadly i wasn't able to get a complete answer, so i remain stuck on this problem. the Matlab function pdepe seems to only be able to solve 2nd ...
1
vote
2answers
133 views

Code for shallow water equation

I want to write a MATLAB code for Roe solver for 1D shallow water equations. Is there anyone who can help me with that?
1
vote
1answer
87 views

Matlab integral with vectorized bounds, without using a loop

I have a simple question that I wasn't able to find an answer to. I have a function f(x) where x is some vector, for example: ...
2
votes
1answer
47 views

Is more robust to digit cancellation the sum operator or the mean operator?

Note: this question is not strictly related to Matlab or any other environment (even though I would prefer that you refer to my Matlab code). I've n = 10000 ...
0
votes
1answer
155 views

How to solve my PDE's in Matlab?

I need to solve a set of 5 PDEs for functions $u(x,t)$. I looked up the Matlab function pdepe. It looked perfect for my case, until I read the line: ...
0
votes
0answers
99 views

Preconditioned Conjugate Gradient linear system solver in MATLAB

I have been trying to use the MATLAB's pcg() function to minimize an energy functional. Converting minimization problems to the solution of a linear system is ...
3
votes
1answer
104 views

Solving linear systems with ill-conditioned matrices

As per suggestions of the people from MathOverflow, I'm reposting my question here: I'm currently trying to solve a linear system $Ax = B$, where the matrix $A$ is ill conditioned (i.e. nearly ...
0
votes
1answer
110 views

Introduction to Lattice Boltzmann methods [closed]

I am trying to learn the Lattice-Boltzmann method and was looking for some good beginner resources explaining the method. I have been looking at some codes online, but have been having trouble ...
0
votes
1answer
68 views

How to create node to node lumping

I have been doing finite element analysis using Matlab. I look for many examples and tutorials producing only the stiffness matrix letting elements being weightless. However, in my case i need to do a ...
1
vote
2answers
96 views

How to solve a constrained optimization problem using minFunc or minConf

I am trying to solve the following optimization problem: \begin{align} &\min\limits_{s} \rm{tr}\left(S^T S\right) + \mathrm{tr}\left(\left(S^T S\right)^{-2}\right)\\ &\text{subject to ...
1
vote
1answer
45 views

Calculate the intersection of two matrix kernels in MATLAB

If we have a discrete saddle point problem with the coefficient matrix $$ \mathcal{A} = \begin{bmatrix} A & B^T \\ B & 0 \end{bmatrix}, $$ then $\mathcal{A}$ is invertible, supposing ...
3
votes
3answers
101 views

How to assemble Global matrix (for coupled) problem?

I'm trying to assemble global matrices for the following system. $$ \begin{bmatrix} K& Q\\ Q^T&S \end{bmatrix} \begin{bmatrix} u_h\\ p_h \end{bmatrix} = \begin{bmatrix} f_u\\ f_p ...
0
votes
3answers
193 views

Numerical simulation of a reaction-diffusion system on MATLAB with finite difference discretization of spatial derivative

I have a model of a system which consists of diffusing reactants and intermediates. For each variable, $u_i$, the final representative equation looks like the standard reaction-diffusion form: ...
0
votes
1answer
83 views

How can I generate 3D unstructured mesh on MATLAB

I have been looking to do a 3D mesh for a shallow tunnel FE analysis. The output of mesh node orientation along the element should be counter clock wise direction. How and which material helps me best ...
0
votes
0answers
22 views

How to apply asymptotic matching condition in bvp4c?

I want to know how to write the code to apply asymptotic matching condition? In the paper, it is stated that they apply asymptotic matching condition for the range of ...
0
votes
0answers
54 views

Calculating derivatives

I have this formulation and want to calculate its derivatives using a mathematical software, either Matlab, Mathematica or anything else. Is there any way by which I can obtain the second equation ...
1
vote
0answers
18 views

How to find active region in treepartition Matlab object

I am trying to identify a non-linear plant using the identification toolbox of Matlab. In particular I would like to identify a non-linear arx model, where the nonlinearities are expressed by means ...
0
votes
0answers
39 views

3D plot from Fourier coefficients in Matlab

I would like to construct a surface on a 2D mesh, given a set of Fourier coefficients for the original function $V(x,y)$. Given some $\mathbb{K}\subset \mathbb{Z}^2$ I have a partial double sum of a ...
1
vote
0answers
37 views

I need to deconvolve the image of a fluorescent bead without the Point Spread Function in MATLAB

I am aware that I could use deconvolution algorithms such as LUCY, Weiner and Blind but I am confused as to how to estimate the PSF (point spread function), which is needed for the LUCY and Weiner ...
1
vote
1answer
66 views

Solving second order SDE with Gaussian white noise for first time derivative in Matlab

I'm having trouble solving a second order differential equation with Gaussian white noise. The equation I'm solving follows the form: $$Ax'' + Bx' + \sin(x) = i + i_{n}$$ where $i_{n}$ is the ...
0
votes
0answers
79 views

Solving first order system in MATLAB

I have problem to solve this in MATLAB. The equation already in first order system, yet I still confused to write the code and solve it. Or this equation cant be solved by using bvp4c perhaps? ...
0
votes
0answers
28 views

Shooting method MATLAB upper order non linear ODE [duplicate]

How can I solve a system of nonlinear differential equations using Matlab? I know I need to use the shooting method but how should I do it? I know I have to control the value of f'' so that it ...
1
vote
0answers
79 views

3D Diffusion Equation in Fourier space

I'm solving the 3D Diffusion equation $$u_t=k(u_{xx}+u_{yy}+u_{zz})$$ in MATLAB using Fourier techniques. I assume a 3D Fourier expansion $(e^{-ipx},e^{-imy},e^{-imz})$of the solution. Physical ...
3
votes
1answer
87 views

How can I minimize the number of non-zero elements in the solution vector subject to linear constraints (MATLAB)?

all, I've tried to find an answer to this question and have come across some related threads but nothing I was able to apply to my problem given my relative lack of experience in this arena. I ...
0
votes
0answers
40 views

Extracting sinograms from tomography projections

my name is Lorenzo and I am a postdoc researcher in Italy. My job is related to tomography imaging using synchrotron radiation. This is a new field for me and I start to face with Matlab to write some ...
7
votes
3answers
162 views

How to compute the rank of a large sparse matrix in MATLAB

I am interested in computing the ranks of fairly large, the largest being of magnitude $10^6$ x $10^6$, sparse matrices whose entires are all 0, 1, or -1. I have been trying to use Matlab to ...
1
vote
1answer
145 views

Shooting method - Matlab ODE

I'm trying to solve these equations of hypersonic adiabatic flow over a flat plate. I did all the simplifications and got these equations for the stagnation point flow. $$\left(Cf''\right)' + f f'' = ...
3
votes
1answer
140 views

Solving system of 7 nonlinear algebraic equations symbolically

I have a system of seven nonlinear equations that I want to find their symbolic solutions. The solution will depend on the parameter K, and I should have different solutions by varying the parameter. ...
-3
votes
1answer
142 views

How can I solve stiff equations by method of line (MOL)?

I want to solve 7 coupled equations.I use method of line(MOL) and discrete the equation in Length and radius and convert them to a system of ODEs in time.and use ode15s to solve them in MATLAB. But an ...
1
vote
3answers
117 views

solving PDEs in MATLAB

I want to solve 3 coupled equations. I converted them to a system of odes in time and discrete it in Length and radius. Now I have a problem in one of the equations in first point. Because in this ...
4
votes
2answers
118 views

Known issues with eigenvalue numerics?

Are there any known issues (such as precision issues) with $\mathsf{MATLAB}$ eig and charpoly functions for large enough $\{-1,0,+1\}$ matrices? Even if I change $1$ or $2$ entries between matrices ...
3
votes
1answer
85 views

Is the “practical” complexity of linsolve direct solver O(n^2) ?

I recently timed the linsolve direct solver and I was kind of shocked to see that the solver seemed to be scaling quadratically even upto a 1000 dimensions. Specifically I ran the following code and ...
0
votes
0answers
43 views

pdist octave/matlab

I am using MATLAB's pdist function to calculate the pairwise distances in 3D. So far, my data is stored in an array called r, ...
0
votes
0answers
33 views

maltab ode solver- user defined criteria to stop calculations

is there a way to add a user defined convergence criteria to an ode solver so that the solution is stopped? I know that Matlab uses absolute and relative tolerances but would that suffice in solving ...