Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
6 views

Finding random points and the $x$and $y$ intercepts of two implicit curves in Matlab

I plotted two implicit functions ($f_1$ and $f_2$) in Matlab using the function fimplicit(f1,[0 1 0 10]) fimplicit(f2,[0 1 0 10]) and I had the following figures ...
0
votes
0answers
13 views

Initial guessing to bvp4c MATLAB

I am working on a 4th order non-linear variable coefficient homogeneous ODE bvp. I am having issues getting a solution using bvp4c. This could be one of many things. Not having a solution within the ...
-2
votes
0answers
10 views

SVR parameters Optimization using GA

I'd like to optimize three parameters (c[2^-5,2^15], sigma[2^-5,2^3] and zta [0.01,0.6] and ...
0
votes
0answers
15 views

Extract data from Matlab cell [on hold]

As result of calculation I got p as 1x5cell. When I open p every cell contain 93x4 double It means beta=5, so 5 times: 93x4 double, 93x4 double, 93x4 double, 93x4 double, 93x4 double Every of ...
1
vote
1answer
41 views

sequence converges to different value

Im trying to study the sequence $$ x_{i+1} = 111- (1130-3000/x_{i-1})/x_i $$ with $x_1=11/2$ and $x_2 = 61/11$ Now, I implemented it in Matlab to see the behavoiur: ...
0
votes
0answers
21 views

Numerical modeling of a leaking oscillator

I have recently been trying to create numerical programs in Matlab to find solutions for physical systems, and whilst researching about varying mass systems I came across a lab report, (where link and ...
1
vote
1answer
52 views

Solve advection equation $v_t + v_x = 1$ numerically with Matlab

Consider the advection equation $$ v_t + v_x = 1 $$ with initial condition $$ v(x,0) = \begin{cases} \sin^2 \pi (x-1), & x \in [1,2] \\ 0, & \text{otherwise} \end{cases}$$ Clearly, we ...
-1
votes
0answers
26 views

FFT in 3D to find central frequency- matlab

So I've been assigned a problem wherein I need to identify the central frequency from a set of 20 1x262144 arrays by averaging the signal replicates in fourier space. I'm comfortable with this type ...
0
votes
1answer
32 views

Simple harmonic motion, RK4 method, matlab plot

So I am having a issue plotting a simply harmonic motion of the form $$\frac{d^2y}{dx^2}+\frac{k}{m}y=0$$ Using the RK4 method in matlab. The issue is that my code is not producing the expected ...
0
votes
0answers
24 views

Explain Matlab ode45 output. Is ode45 an iterative algorithm? [closed]

I tried to use ode45 to solve an equation, and get output like the following. I get the idea it is trying to estimate using nearby points (as explained here https://www.mathworks.com/videos/solving-...
0
votes
0answers
30 views

Matlab troubles [closed]

If A and B are vectors, what is the MATLAB command whose output is the vector (3/2)(2A+B)? Store this command as text assigned to the variable TwoBcode. Is the asking me to store the variable or ...
0
votes
0answers
21 views

Correlation distance

I'm computing the correlation distance with Matlab (https://de.mathworks.com/help/stats/pdist2.html#d120e570586). The purpose is to calculate the distance between two histograms. My source says, that ...
-1
votes
0answers
14 views

Gaussian Normalization Method

Kindly I have searched for Gaussian Normalizing method but could not find it. Please, could you guide me? what is the equation, and how it is work? Thank you
0
votes
1answer
27 views

What numerical method does Matlab's bvp4c use?

Can anyone shed some light on how matlab's bvp4c function works? I've looked online but I haven't found any specifics on the method it uses. With that question asked, what are some different ways on ...
0
votes
0answers
28 views

Solve 2 equations in 2 unknowns in octave?

I have the following 2 equations in 2 unknowns $(x,t)$: $(t*x-20)^4 = 100*((t*x-20)^2-t^2(150^2-x^2)) $ $(t*\sqrt{(150^2-x^2)}+70) = ((t*x)+30)*tan(arctan(7/3)+36*t)$ I tried solving them ...
0
votes
1answer
16 views

How do I plot an “unarranged” array1 vs array2 in MATLAB?

I have to plot two arrays: array1= [ 0.6321 0.6640 0.6997 0.8574 0.8824 0.9222 0.0893 0.1310 0.1600 0.3251 0.4008 0.7528 0.7985 0.9871 0.0417 0.2209 0....
0
votes
0answers
17 views

Distribution property on the internal and external multiplication of matrices

I have relation as : A=E*(p1.p2)=270 which E=[1 2 3]; p1=transpose([4 5 6]); p2= transpose( [7 8 9]); How can I withdraw p2 or make a factor from p2 f to make isolate (Ep1)
2
votes
2answers
62 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 ...
2
votes
1answer
34 views

MatLab: Not Enough Eigenvectors for (Repeated) Eigenvalues

I am trying to make a code that matches the eigenvalues to eigenvectors for one of my projects and I am new to MatLab. I get a 3x3 matrix output when it comes to eigenvalues and a 3x2 when it comes to ...
-1
votes
1answer
46 views

First passage time distribution in birth-death processes

I'm working on the following birth-death process $$X\rightleftharpoons A$$ in which the birth and death (transition) rates are $t^+=k_2a$ and $t^-=k_1n$ respectively. $n$ is the concentration of $X$...
-2
votes
1answer
73 views

Using MATLAB to solve Poisson matrix equation

I'm not sure if this is the correct forum to post my question. I'm working on a Poisson-based maths assignment and am stuck as regards finding the solution to the Poisson matrix equation. The matrix ...
1
vote
1answer
57 views

Matlab code for $y_{n+2} - y_n = h\left[(1/3)f_{n+2} + (4/3)f_{n+1} + (1/3)f_n\right]$

I am looking for a Matlab code for the $2$ stage multistep method : $$y_{n+2} - y_n = h\left[(1/3)f_{n+2} + (4/3)f_{n+1} + (1/3)f_n\right]$$ Note that $f_n = f(x_n,y_n)$. Now, since $f_{n+2} = f(x_{n+...
0
votes
0answers
29 views

From direction cosine matrix to Cardan angles - Two different Matlab codes, different results

I have two Matlab codes to get the Cardan angles (ZXY sequence) starting from a given direction cosine matrix (dcm), but the results are different. Why? The dcm is: ...
1
vote
0answers
12 views

How to define in Matlab a function with a 3 variable input as a function with a vector input

Say that I want to write an m-file to find the value of the following function: $f(x,y,z) = \frac{1}{2}\left[\left(2 x-yz-1\right)^{2}+\left(1-x-y - exp(x-z)\right)^{2}+\left(-x-2y+3z\right)^{2} \...
0
votes
0answers
38 views

Numerical analysis: least squares method

Basically I came up with a function where I need to approximate it using the least squares method. I had no trouble computing the constants on MATLAB and got to the following plot: Now as you see the ...
0
votes
0answers
33 views

Matlab function which will perform the analysis of my system with respect to Control Theory.

$x`(t)=Ax(t)+Bu(t)$ $y`(t)=Cx(t)$ I have three matrices. For example, the matrices are: And using only one Matlab function I would like to get the following information: 1 Eigenvalues of the ...
-1
votes
0answers
50 views

Numerical solution to 1D convection-diffusion equation

I am looking to numerically solve the convection-diffusion equation $$ \frac{\partial p}{\partial t}=-\frac{\partial}{\partial x}\left(u(x)p(x,t)-D(x)\frac{\partial p}{\partial x}(x,t)\right) $$ where ...
3
votes
0answers
39 views

How to deal with the non-uniqueness of SVD in numerical applications?

There are many applications in applied mathematics where the SVD of a matrix comes in handy. For example, consider the problem where we want to find an approximate solution to a(n) (overdetermined) ...
0
votes
0answers
14 views

matlab - Optimization with inverse and pseudoinverse

Let us assume I have to optimize this system: $$\min_{x\in S} \left|\left|\left(E\begin{bmatrix} I_n\\ A'(x)^{-1}C'(x)\\ \end{bmatrix}\right)^+ a -b\right|\right|^{2}$$ Where x is the vector ...
1
vote
1answer
49 views

Hermite interpolation code in MATLAB

This is my MATLAB code for divided differences and Hermite interpolation, but it doesn't work properly. Could you take a look at it? Thank you. I'm sorry for the layout, but it's the best I could do. ...
1
vote
0answers
15 views

Discretization of continuous model with white noise to use Kalman filter later

I have this system which describes dynamics of a car in 2D space. The dynamics are governed by Newton's law g(t) = ma(t). The final task is to use Kalman filter on discretized system to estimate it's ...
0
votes
1answer
33 views

Matlab script for a dynamical system [closed]

The code ...
0
votes
0answers
45 views

How to program numerical integration $\int_t^{\infty}\frac{1}{(u+1)^2}du$?

I'm facing a problem when program the numerical integration of $\int_t^{\infty}\frac{1}{(u+1)^2}du$, I know that the true value is $\frac{1}{1+t}$, however, when I want to calculate the definite ...
1
vote
1answer
52 views

What is the motivation behind naming identity matrix as “eye”?

Matlab, as well as some other PLs (e.g. Python's numpy package) use "eye" as a function name for creation of the identity matrix. Why is that so?
0
votes
1answer
41 views

Efficient way to do a Fourrier Transform like operation

Suppose we have two functions $f,g:[0,\infty) \rightarrow [0,\infty)$. Then one can use Fast Fourrier Transforms to quickly compute $\int_0^t f(t-s) g(s) \, ds$ for $t$ in some range of values $[0,T]$ ...
0
votes
1answer
34 views

Confusion regarding Kelvin functions

I am trying to implement the following equation from this paper and having some troubles in the interpretation of $bei'$ and $ber'$. I understand from the definition of Kelvin functions that for ...
0
votes
0answers
14 views

Finite difference method for the third order partial differential equation

I would like to use the finite difference method for the initial problem of the following form: $$u_t(t,x) + u_{xxx} (t,x) = f(t,x), u(0,x) = u_0(x).$$ I have a compatible difference scheme for it, ...
0
votes
1answer
37 views

simulate random variable from pdf (discrete case)

I am trying to simulate n random discrete variable which has the following pmf $P(X = k) = (1-p)^2kp^{k-1}$ I am thinking about using the inverse transform sampling method and I am trying to find ...
0
votes
0answers
14 views

Summation with independent variables as different sized arrays in matlab

I am new to matlab and am learning it on my own. I am trying to solve and graph the following summation in matlab ...
1
vote
3answers
64 views

Is $det(A)=0$ a good indicator to say that a matrix is not invertible?

In finite elements, for example, appears huge sparce (CRS) matrices (matrices with a lot of zeros). It is possible that matlab (or some other program) calculates $det(A)=0$ even though the matrix is ...
0
votes
0answers
12 views

PDE with Robin Boundary Condition at alpha Solving with Poisson's Equation

Using a code like this, I am having a hard time applying a Robin Boundary condition for a instead of a dirichlet for the following problem: IMG OF QUESTION FOR POISSON ROBIN BC Nx = ...
0
votes
0answers
22 views

fsolve and fimplicit for a non-linear equation

It's well known that from time to time nonlinear solver fsolve in Matlab gives controversial results but I'd like to ask and simultaneously share my experience of the exploitation of this command. I ...
2
votes
2answers
37 views

Confused about the terminology of least regression squares

I am confused by the language of my math text book where it says $\hat y = \alpha \times$basis function summation from $i=1$ to $n$? What are basis functions? And why does it says there are more data ...
1
vote
0answers
20 views

Nonlinear optimization of a matrix with the costraint to be orthonormal

I'm trying to find the matrix x which minimize the following cost function : $J =||B_b -x*B_n||^2$ with the constraint that x has to be an orthonormal matrix. I'm trying to use MATLAB fmincon tool, ...
0
votes
1answer
34 views

Im confused with Least Squares Regression Derivation (Linear Algebra)

I am having troubles understanding Least Squares Regression Derivation (Linear Algebra) in order to code it in matlab. As far as I have understood, is that you take the residual value = (yhat - y)^2 . ...
1
vote
1answer
74 views

MatLab: Motion of charged particle in electromagnetic field in cylinder

We wish to solve the differential equations for a particle's movement in a electromagnetic field inside a cylinder. This has to be done using the a non built-in Runge-Kutta method of the 4th order. We ...
0
votes
1answer
22 views

Is it possible to evaluate error of numeric schemes by using integrals?

I'd just like to know if it is possible to evaluate the error of a numerical scheme by using it's solutions integral? To elaborate this. I have long transmission line, which I evaluate over time ...
1
vote
2answers
33 views

Phase plot of a system of differential equations using Matlab

Assume the system: \begin{align} \begin{pmatrix} x \\ y \\ \end{pmatrix}' &= \begin{pmatrix} 7x+10y+3 \\ -5x-7y+1 \\ \end{...
0
votes
0answers
26 views

Logical indexing and for loop question Matlab

I have a vector p=[-3 -2 -1 0 1 2 3], and an expression like $\psi_p=a~e^{ikp}+b~e^{-ikp}$ for $-3\leq p< 1$ and $\psi_p=c~e^{ikp}$ for $1\leq p\leq 3$; $a$, $b$...