# Questions tagged [matlab]

For mathematical questions about MATLAB; questions purely about the language, syntax, or runtime errors would likely be better received on Stack Overflow. MATLAB is a high-level language and interactive programming environment for numerical computation and visualization developed by MathWorks.

2,621 questions
Filter by
Sorted by
Tagged with
1k views

### Reconstructing space curves from its curvature and torsion

I have to write a program which gets two functions (curvature and torsion) and 3 vectors of the Frenet-Serret "frame" at the starting point - and I have to reconstruct the space curve from this given ...
751 views

### How to generate and use random trees?

I have the assignment to implement a random tree classifier in MATLAB. The lecture says: ...
60 views

### Solve issue with Matlab 2018b version

I was very successfully solving an equation numerically in Matlab R2014a with the following code ...
83 views

### Numerical methods for the matrix ODE $\dot L(t)=[L, \Pi_m(F\circ L)]$

Suppose $L$ is a lower-triangular matrix whose row sum is $0$. I want to numerically solve the following matrix ODE $$\dot L(t) = [L, \Pi_m (F \circ L)], \qquad L(0)=L_0$$ where $[\cdot \,,\cdot]$ ...
50 views

1k views

### determinant of a very large matrix in MATLAB

I have a very large random matrix which its elements are either $0$ or $1$ randomly. The size of the matrix is $5000$, however when I want to calculate the determinant of the matrix, it is either $Inf$...
6k views

### Projection matrix onto null space

I have a matrix $H$ and I want to find the projection matrix onto null space. How can I do this?
19k views

### Compute Angle Between Quaternions (in Matlab)

I am working on a project where I have many quaternion attitude vectors, and I want to find the 'precision' of these quaternions with respect to each-other. Without being an expert in this type of ...
6k views

### Phase shift of two sine curves

How do I determine phase shift of two sine curves (discrete time sampled sine curves) in Matlab. Currently, I have the FFT of these two sine curves, the phase shift is just the delay in time, which ...
3k views

### Simulating Diffusion/Wiener Process with Random Walk

I hope this is the right section for this kind of questions. I am trying to simulate, with MATLAB, a diffusion model starting from a Random Walk. I am using a Random Walk with information increment ...
85 views

### Changing [2,4] into [0,1,0,0,0,1] in Matlab

Good day, I apologize for the very vague title, I didn't really know how to formulate what I want. However, I can explain what I mean: I have a vector v1: ...
5k views

### Finding D matrix in LDU in matlab

I have been searching the web for nearly 3 hours about a MatLab function that can take matrix A and give me back L, D, and U. ...
2k views

### Matlab code for computing index of matrix

I need help to make Matlab code for computing index of matrix. The index of matrix $A$ is the least non negative integer $k$ such that $\operatorname{rank}(A^{k+1}) = \operatorname{rank}(A^k)$. ...
28k views

### Matrix is singular to working precision

I have a problem while evaluating inverse using inv in MATLAB. My matrix looks like this: ...
2k views

### Multivariate normal value standardization

I am wonder how to standardize multivariate normal value. Normal standard multivariate distribution of $q$ variables is $z\sim N_q(0,I_q)$. I have found that $a+Bz\sim N_q(Ba,BB^T)$ and based on this ...
348 views

### Runge Kutta stability

I am facing a problem solving a ODE with a Runge-Kutta 4th order method: The expression in order to solve is : $$Ay^{''}+By^{'}+Cy= Cu$$ y =OUTPUT \end{...
11k views

### Eigenvectors in Matlab/Octave, function “eig()”, why are the eigenvectors output like that? [closed]

You can calculate eigenvectors of a matrix with eig() function like this: [eigenvectors, eigenvalues] = eig (matrix) But I can't manage to understand why the eigenvector output is in some kind of ...
20k views

### Understanding Fourier transform example in Matlab

I'm studying about Fourier series and transform and I get confused with the following Matlab example of Fourier transformation: ...
6k views

### Which optimization algorithm converges faster?

everyone. I'm having a large scale unconstrained optimization problem. If I treat the unconstrained problem as a constrained problem with infinity constraints, I should be able to use both the ...
1k views

### A problem for Matlab solver

I can numercally solve a system of two ODEs for x and p: dy1 = -y1 + y2 dy2 = -1 + y2 with the following Matlab code: ...
960 views

### Efficient multiplication of super-size matrices in matlab

I don't have enough memory to simply create diagonal matrix D x D, getting an 'out of memory' error. Instead of performing M x D x D operations in the first multiplication, I do M x D operations, but ...
76 views

### Calculating value of $\text{sinc}(x)$, WolframAlpha and MATLAB give two different answers.

I need to evaluate the following: $$\frac{2}{3}\text{sinc}\bigg(\frac{2\pi}{3}(n-4)\bigg)-\frac{1}{3}\text{sinc}\bigg(\frac{\pi}{3}(n-4)\bigg)$$ for $n=[0,...,8]$ I don't have the sinc function in ...
1k views

3k views

### Roll PID Control for quadcopter

I'm trying to implement with simulink a PD controller for my quadcopter. I use a simplified model, and for the roll case I have $I_x * \phi = L$, where L is the roll torque. So, the transfer ...
949 views

So I am trying to get matlab to output the correct eigenvalue/eigenvector of a matrix. The matrix is: \begin{array}{ccc} 0 & 1 \\ -3 & -4 \end{array} The eigenvalues are: $\lambda_1 = -1, \... 5answers 2k views ### Round a set to the nearest values in another set (2D), faster algorithm with Matlab Given a set of numbers, like A={{1,2.5,3}, {4.2,7,10}}; and another set of numbers, like B={1,2,3,4,5}; Is there a fast ... 3answers 15k views ### Normalizing a Gaussian Distribution Assuming a Gaussian distribution with mean of zero and standard deviation of one, I would like to normalize this for an arbitrary mean and standard deviation. I know you're supposed to add the mean ... 3answers 2k views ### Why is MATLAB giving me these weird eigenvectors? I am doing a problem which involves finding the eigenvalues and eigenvectors of the matrix $$M=\begin{bmatrix} 0 & 1/2 & 1/2 \\ 1/2 & 0 & 1/2 \\ 1/2 & 1/2 & 0 \end{bmatrix}$$ ... 1answer 5k views ### Can't understand a simple wave equation matlab code I'm trying to figure out how to draw a wave equation progress in a 2D graph with Matlab. I found this piece of code which effectively draw a 2D wave placing a droplet in the middle of the graph (I ... 2answers 365 views ### Finding nearest left and right root using Newton-Raphson The following is a problem in a Numerical Methods class. Consider the following function: $$f(x) = x^3 - \frac{31}{10}x^2+\frac{1}{10}x+\frac{21}{5}$$ Implement a method that will allow ... 2answers 165 views ### Minimize$\|AXBd -c \|^2$, enforcing$X$to be a diagonal block matrix Currently, I am minimizing the quadratic objective$\|\mathbf{A}\mathbf{X}\mathbf{B}\mathbf{d} -\mathbf{c} \|^2$using CVX, as follows ... 2answers 135 views ### Why does using the identity$e^x=1/e^{-x}$work better in evaluating negative numbers in the finite taylor series expansion of$e^(x)$Was in class where we look at both and notice that there is a difference in the error, but we didn't go into why. The other method used the taylor expansion$$e^x=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+...$...
I want to find the solution of a Lagrange equation whose inputs are matrices. First I have the equation Ax=0. By decomposing $A$ into $A_3$ (columns 9 to 11 of A), $A_9$ (the rest of the columns), ...