Questions about the numerical programming language MATLAB.

learn more… | top users | synonyms

-2
votes
0answers
29 views

plot graph in x, y and z coordinates using MATLAB

Anyone can solve this? Given a wave with an electric field E = 4 cos (ωt)a_X and magnetic field H = 2 4 cos (ωt)a_y. Both field travel at z direction. Plot the graph for those fields in x, y and z ...
0
votes
0answers
60 views

MATLAB: code for restarted gmres

I have a question about Matlab and restarted gmres. I would like to use gmres.m provided here. This code seems to be a popular for the scientific computation ...
0
votes
1answer
32 views

Dealing with errors in non-linear least square problem

I am currently working with a optimization problem involving a non-linear least square problem. I have chosen to use lsqnonlin in Matlab. What follows is a ...
0
votes
0answers
53 views

Frank Wolfe algorithm in matlab

I'm trying to solve the following question : $$ maximize \ x^{2}-5\cdot x + y^{2}-3\cdot y $$ $$ x+y\leq 8 $$ $$ x\leq2 $$ $$ x,y\geqslant 0 $$ By using Frank Wolf algorithm ( according to ...
1
vote
1answer
36 views

Why does `symrcm` create larger band width?

When I run the following (in Matlab) on a sparse matrix $A$, I get larger band width. The symrcm (symmetric reverse Cuthill-McKee permutation) is not guarenteed to ...
0
votes
0answers
28 views

Matlab PDE toolbox

I'm new at matlab and I can't figure out how to make external temperature not constant but as a function. I wanted to use pde toolbox, I choose parabolic type. My external temperature should be ...
3
votes
0answers
37 views

2D wave equation with Mur boundary condition - setting up the RHS and solving (time-steps)

I am trying to solve a 2D wave equation implicitly using FD with central approximations with the following boundary conditions $$\begin{align} &u=2\sin\left(\frac{2\pi}{5}t\right)\quad \text{at ...
1
vote
1answer
51 views

Instability of pdepe in Matlab… boundary conditions?

here is a Matlab beginner banging his head on the wall... I am trying to solve a system of partial differential equations in Matlab, with both derivatives in time and space domains. I am using the ...
0
votes
1answer
72 views

Solving a PDE using Matlab (with varying initial conditions)

I want to solve a 1-D heat conduction PDE using Matlab which looks like $$ \rho c_p \dfrac{\partial T}{\partial t} = \dfrac{\partial}{\partial z}\left( \lambda \dfrac{\partial T}{\partial z} \right), ...
0
votes
2answers
47 views

Compute the intersection of convex sets in Matlab

I'm aware of a Matlab function which take a set of point as an input and select the points which compose the convex hull. Exemples from Mathworks website : ...
0
votes
0answers
32 views

Could anyone help me with dde23 function

I have been trying to graph these equations using dde23 but keep having a error. This is very important for my presentation so I would really appreciate any help ...
0
votes
0answers
48 views

How to solve a nonlinear diffusion equation?

Consider a thin film with a perpendicular applied magnetic field Ha in z-axis. The nonlocal relation between Ha, the self-field Hself (generated by the eddy current J) and the local magnetic flux ...
1
vote
1answer
91 views

Simple integration in Matlab is off

This is an incredibly mundane integration, but for some reason I can't spot the error. I am just performing a simple 3d integration in spherical coordinates which should return the value of 1.0: ...
1
vote
0answers
59 views

Calculate Integral Using Gauss Jacobi Quadrature or otherwise

I need to integrate the following integral: \begin{align} I = \int^z\frac{1-\zeta^2}{(1+\zeta^2)(\zeta-\zeta_l)(1-\zeta_l\zeta)}\prod_{k=2}^{n-1}\left ( \frac{\zeta-z_k}{1-\zeta z_k} \right ...
0
votes
0answers
59 views

Solving PDE with state and time dependent boundary conditions

I am interested in solving the following PDE (heat equation): $$\frac{\partial u}{\partial t} = \kappa \frac{\partial ^2 u}{\partial x^2}$$ In order to solve it, I discretize space uniformly into $N$ ...
-1
votes
1answer
38 views

How do I stop negative numbers and error message: " Failure at t=3.562559e+03. Unable to meet integration tolerances

I am using 8 ODEs in Matlab to simulate the effect of asymptomatic infections in the epidemiology of a vector borne disease. Searching the parameter space under certain settings produces negative ...
0
votes
1answer
62 views

How to speed up fmincon in MATLAB when there are many variables? Alternatives to MATLAB optimization toolbox?

I need to solve an optimization problem with two nonlinear equality constraints. My function evaluation is very fast (less than a second) and I also provide fmincon ...
0
votes
1answer
41 views

How can I plot the Ramachandran regions in MatLab?

I have a scatter plot where I need to shade the Ramachandran allowed regions for aminoacids. I know there is a function that plots them for you, but it is not helpful for my case since I need the ...
0
votes
0answers
55 views

Plane Wave expansion method in matlab

I am a new member of this forum and I was trying to understand Plane Wave expansion simulation in Matlab. So far I cannot understand how to simulate Gz vector in K-space consistently to the numbers of ...
1
vote
0answers
37 views

Using Centroid decomposition instead of SVD

This paper says centroid decomposition (CD) is an approximation to singular value decomposition (SVD). First I do not understand CD yet, since code is available I just want to try it out how it works ...
5
votes
2answers
152 views

Why is Matlab's SVD faster on skinny matrices than on fat matrices?

I noticed something odd today. I have a matrix X that is very skinny (20800 x 200), double precision real numbers, not sparse, ...
1
vote
2answers
93 views

Incremental SVD implementation in MATLAB

Is there any library/toolbox which has implementation of incremental SVD in MATLAB. I have implemented this paper, it is fast but does not work well. I tried this but in this also error propagates ...
0
votes
0answers
67 views

parallel computatioan of a PDE in MATLAB

I want to solve a 1-D PDE $(\partial_{tt} + \alpha\partial_t)u(x,t)=\partial_{xx}u(x,t)-\sin(u(x,t))+f$, using method of lines and for this I defined a spatial grid of about n~1000 points. Since my ...
1
vote
2answers
102 views

How to solve ODEs with constraints using BVP4C?

I am using BVP4C to solve a system of ODEs which is as follows. \begin{equation} \left\{ \begin{aligned} \frac{\partial f(x,y)}{\partial x} &- ...
3
votes
1answer
115 views

Software for triangulating a point set (with restrictions)

I want to triangulate a point-set like the one below. I would like the triangulation of the point-set to have the following properties The triangles must have as vertices the black and orange ...
0
votes
1answer
66 views

MATLAB: Backslash operator using symbolic variables with an overdetermined system

I have an overdetermined system (too many equations), expressed as Ax=b, in MATLAB. When I try to solve it using A\b, I receive the error: ...
2
votes
0answers
80 views

1 D Diffusion equation FDM with different layers

I'm trying to solve this particular equation $\frac{\partial u}{\partial t} = \frac{\partial}{\partial x} \big[D_{i}(x)\frac{\partial u}{\partial x} \big] + S(x,t)$ where the $i$ index denotes ...
3
votes
1answer
67 views

Integration including bessel function

I’m trying to evaluate an improper integral of a 0th order Bessel function of the first kind using Matlab: v = integral(@(x)besselj(0, x), 0, Inf) which returns ...
1
vote
1answer
41 views

Is it possible to locate an image in a video using MATLab?

I'm not a huge programmer, but if it'll save me lots of time, that's when I code (given that it's possible). I know MATLab has a Computer Vision Toolbox, so my question is: is it possible to program ...
0
votes
2answers
96 views

How can I reduce integration tolerance in matlab?

It was said in a comment that I should recude integration tolerance to eps. What does this Matlab error message mean? I read the manual and I still don't know how to do it. Can you please tell me how ...
1
vote
1answer
58 views

Sparse linear system of certain type

Let $n_1,n_2 \in \mathbb{N}$ and $n=n_1n_2$ and $b\in \mathbb{R}^n$. I have a SPD-matrix $A=(a_{i,j})\in \mathbb{R}^{n \times n}$ with $a_{i,j}=0$ if $|i-j| \notin \{0,1,n_1\}$. Can we solve the ...
1
vote
1answer
60 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
50 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
14 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 ...
3
votes
2answers
106 views

Why do structured and unstructured discretizations give different errors?

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
1answer
40 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
72 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
42 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
118 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
57 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
39 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
116 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 ...
5
votes
0answers
110 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
44 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
63 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
125 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
58 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
122 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
54 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
99 views