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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
7 views

Approximating (projecting) a surface with bivariate polynomials

I'm working on something and got stuck. First some background: say we have a given continuous function $f(x,y)$ that we want to approximate with the best polynomial (discrete least squares) $z_{n}(x,y)...
user avatar
1 vote
0 answers
24 views

Numerical solution of $2D$ wave equation using Fourier transform and finite differences

This is the $2$-dimensional wave equation $$ u_{tt} = u_{xx} + u_{yy} $$ with initial condition $u(x,y,0)=f(x,y)$ and $u_{t}(x,y,0) = 0$. The inverse Fourier transform used is $$ u(x,y,t) = \iint \hat{...
user avatar
  • 4,202
0 votes
0 answers
15 views

I am unable to plot system differential function on octave.

So I am given a system of 1st order differential equations along with initial conditions. I need to solve and plot graph on octave. I have successfully solved and obtained the equation but now I cant ...
user avatar
-1 votes
0 answers
21 views

Write an effective algorithm of solving system of linear equations with the nonsingular five-diagonal matrix [closed]

...
user avatar
0 votes
0 answers
6 views

Matlab. Use of decomposition on Block matrix

I am a new to Matlab... I have to code a program Look at picture I attached I almost implemented everything: Crout's Algorithm,LU decomposition and solving linear equations through it. I created this ...
user avatar
0 votes
0 answers
10 views

Matlab. LU decomposition Crout's Method. And usage of decomposition on accurate Block Matrix.

I have to implement such a program()Look at picture I attached I mostly implemented everything: Crout's Algorithm, solving linear equations, I created this block matrix, but I don't know to use that ...
user avatar
-1 votes
1 answer
28 views

Block matrices in MATLAB. [closed]

I am completely new to the matlab programming. Could please tell me algorithm/implementation of the block matrix M(PICTURE). How to code it in Matlab? Thank you.[This Block Matrix M ][1] Block Matrix ...
user avatar
0 votes
0 answers
9 views

Matlab.Block matrices

I have implemented algorithm of Crouts method. But I don't have any idea how to create this M function in Matlab and implement in my algorithm .Please help me. CODE of algorithm: function [L,U] = ...
user avatar
0 votes
0 answers
9 views

Infinite Standard Deviation with Kalman Filter

I'm using a Kalman Filter code on Matlab that produces the results of Stock and Watson 1991 with some macroeconomic variables, GDP and a soft indicator to forecast the economy of a country (everything ...
user avatar
  • 21
0 votes
1 answer
43 views

How can I optimize an experimentally derived objective function?

I have to optimize the result of a process that depends on a large number of variables, e. g. a laser engraving system where the engraving depth depends on the laser speed, distance, power and so on. ...
user avatar
0 votes
1 answer
69 views

How to compute the Fourier transform of a zero-centered Gaussian pulse over a specified range, say $[0,1]$?

Given an even Gaussian kernel $f : \Bbb R \to \Bbb R^+$ $$f(x) = \exp \left(- \frac{1}{2\sigma^2} x^2 \right)$$ and a probability density function (or, if you discretize $[0,1]$, then a probability ...
user avatar
0 votes
0 answers
10 views

LQR design for Augmented system not working.

I am trying to design an LQR for the system matrices given below. The augmented system is a 4-state, 2-input, and 1-output system. I also had to design an observer for the augmented system. The ...
user avatar
  • 1
1 vote
1 answer
27 views

Find the rightmost triangle with respect to the diagonal in a four-sided polygon.

The goal is to find the right triangle, depicted in red, in a four-sided polygon with respect to the diagonal. The four-sided polygon's vertices are known. Initial attempts: The angle formed by the ...
user avatar
  • 13
0 votes
0 answers
30 views

Solving polynomial systems on MATLAB

I'm working on a large polynomial system with 40+ variables and even more equations. I am aware that SINGULAR can ``solve'' it by finding its Groebner basis. However, I have to solve a sequence of ...
user avatar
  • 33
-2 votes
0 answers
24 views

How to accept an empty input [closed]

I have a function that takes as an input a vector "n". I would like to pass an empty matrix "n". My code does not seem to work. k=size(n) if k == 0 n = 1000 ; M = 1:n ; value = 1./(...
user avatar
0 votes
0 answers
36 views

MATLAB Plot $P = \{x|Ax\leq b\}$

So I am having this trouble with plotting my Polyhedral Set defined as $$P = \{x|Ax\leq b\}$$ The thing is I want to plot it in MATLAB. Let's say my matrix $A$ is $A = [1\ 1 \ ;\ 1\ -1;-5\ 1]$, and ...
user avatar
0 votes
1 answer
38 views

Is it possible for define the event function of ode45 solver in matlab in this way?

I want to solve the Van Der Pol equations using ode45 with event function as its stopping criteria. I would like to set the stopping criteria as the slope of $y(3)$ is small enough: $$\frac{\Delta y(3)...
user avatar
3 votes
2 answers
140 views

What is the Matlab code for Newton Raphson method to solve the polynomial system?

I want to approximate the zeros of the following system of polynomial equations using the Newton-Raphson method: \begin{align} f(x,y) &= x + \frac13 y^9 + \frac19 x^{243} + \frac{1}{27} y^{2187} =...
user avatar
  • 9,587
0 votes
0 answers
26 views

Adaptive step size for Euler Method - How to create?

I think Euler's Method is a great way to simulate ODE:s. It's not the most accurate, but it's the fastest and simplest. Euler's Method is usaly used with fixed step size, where ...
user avatar
  • 2,497
0 votes
0 answers
40 views

How to use Monte Carlo method to calculate the volume of a cone inscribed in the unit cube?

unit cube L=1 how do i use random numbers with monte carlo method to calculate the volume of this cone? if anyone can use matlab to solve it, i appreciate it!
user avatar
0 votes
0 answers
12 views

Neumann B.C with an extra term in Matlab

I have written a heat equation with the Neumann boundary condition. I used heat equation with Neumann B.C in matlab. Now how can I add the term $\beta A \frac{\partial u}{\partial x}$ to the equation ...
user avatar
0 votes
0 answers
30 views

Large number of absolute value expressions in constrained, non-convex optimization problem

Say I have a problem given by \begin{align} \min_{x\in\mathbb{R}^n} & \ ||g(x)||_1, \\ \text{s.t. } &z_i(x)+||c^{(i)}(x)||_1 \leq d_i, \ i\in\{1,...,N\}, \end{align} where $g:\mathbb{R}...
user avatar
  • 274
1 vote
1 answer
37 views

How to solve a system of pdes coupled in their boundary condition

Initially i had the following system of pdes to solve: $$\frac{\partial A}{\partial x} =\frac{1}{v_A(y)}.\frac{1}{Pe_A} .\frac{\partial^2A}{\partial y^2} \qquad for \quad 0\leq y\leq \alpha$$ $$\frac{...
user avatar
  • 11
0 votes
1 answer
45 views

SOSTOOLS in MATLAB: findbound gives wrong output

Here is the MATLAB code that uses SOSTOOLS toolbox: ...
user avatar
0 votes
1 answer
92 views

How do I solve this numerical analysis exercise? (Interpolation of even function)

I've been stuck for days now and I just can't solve it. Can someone please solve this exercise or help me with them? Here's what is given: Let $a>0$. (Definition:) A function $f: [−a,a] \rightarrow ...
user avatar
  • 1
0 votes
1 answer
31 views

Difference between numerical and analytical solution of differential equation?

I am solving two differential equations numericaly, in Matlab, and analyticaly. But when I compare results, they are not the same, I cannot conclude why? These are equations: $$x_0' = \dfrac{-32 \beta}...
user avatar
0 votes
0 answers
16 views

Solve 2D heat equation with a sinusoidal source with the Euler scheme and the finite difference method (FDM)

I am trying to solve the heat equation of the following form: $$ \frac{\partial u(x,y,t)}{\partial t} - \Delta u(x,y,t) = q \cdot sin(6.28\cdot x) \cdot cos(6.28\cdot y) \; \; \text{in }(0,1)^2\times (...
user avatar
0 votes
0 answers
10 views

What are the MATLAB syntax for various neural network learning algorithms and activation functions??

I just started learning MATLAB for neural network implementation. I just studied the various activation functions. However, I am confused in their syntax. Please help...
user avatar
1 vote
1 answer
58 views

LQI for angular speed control in MATLAB

With the following state space system and setting for the Linear Quadratic Integrator (LQI) Q = diag([1,1,1]) and r = 1; for ...
user avatar
2 votes
1 answer
32 views

Generating random numbers in MATLAB

Edit: The code is edited and new result is pasted. I am trying to generate random numbers using randi command in MATLAB. I am generating 100, 1000 and 100,000 random numbers, respectively, between 50 ...
user avatar
0 votes
0 answers
15 views

algorithm problem in getting rid of double counting in nearest neighbor list?

I have a list of nearest neighbors; as an example you can look at the following list: tes1=[1 2; 1 3; 1 5; 2 1; 2 3; 2 6]; In this list atom 1 is nearest neighbor ...
user avatar
0 votes
1 answer
29 views

Convolution of 2D functions - Matlab

I need to compute the convolution of two functions in $\mathbb{R}^2$ numerically. Basically, I have two functions, $f(x,y)$ and $g(x,y)$, and I want to compute $f\cdot g$. I have a rectangular domain $...
user avatar
  • 1
0 votes
0 answers
30 views

How to generate a cosine wave with signal generator in Simulink?

I am trying to generate a power spectrum by modeling like the figure: I would like to generate a simple cosine wave: $\cos(2\pi t)$, using a signal generator. However, I could not find a phase shift. ...
user avatar
0 votes
1 answer
49 views

matlab coding - finding shortest path problem

Lately I've been trying to learn MATLAB and there's this project that have been assigned to me which I'm trying to do. the description of the project is as follows: we have a set of 100 points: $${(0,...
user avatar
  • 154
0 votes
0 answers
13 views

Batch Interpolation of Several Curves with Discontinuities

I am starting with several points that each belong to a unique curve. I know a-priori what points belong to what curves, and I have placed the points in the order in which they trace their individual ...
user avatar
0 votes
0 answers
8 views

MATLAB Least Squares Regression Trig Fit

I'm trying to make a best-fit trig function for daily temperature data (some .csv files written via python3). I am using the Cholesky method in MATLAB, but for some reason my best-fit function is not ...
user avatar
  • 1
1 vote
0 answers
58 views

Computationally efficient way to find a $2 \times 2$ matrix [closed]

I have two matrices $A,B \in M(\mathbb{Z}/255\mathbb{Z},n)$, where $M(\mathbb{Z}/255\mathbb{Z},n)$ is the set of the matrices of shape $n \times n$ and coefficients in $\mathbb{Z}/255\mathbb{Z}$, and ...
user avatar
1 vote
0 answers
21 views

How to solve 2D nonlinear Schrodinger equation?

How to get a numerical and explicit answer? I have $iA_t=A_{xx}+A_{yy}+f(x,y,t)A$ $A(x,y,t)=0$ on the border of the unit square $(x,y)\in((0,1)(0,1))$ $A(x,y,0)=u(x,y)=$ ,for example, $=\sin(pix)\sin(...
user avatar
0 votes
1 answer
26 views

Solving BVP with variable coefficient on MATLAB

I have the second order boundary value problem $$ y''=\frac{k}{2\sqrt{t}}\left[Py'-2yy'-y(P-y))\frac{1}{2t} \right], $$ with boundary conditions I will specify later in the code. Setting $y=y_1$ and $...
user avatar
  • 1,008
0 votes
1 answer
58 views

Can we obtain $\sum_{i=1}^n a_i$ from $\sum_{i=1}^n \log a_i$?

Is there a way to obtain $\sum_{i=1}^n a_i$ from $\sum_{i=1}^n \log a_i$? Actually I am trying to compute $\sum_{n=1}^{1000} n!/n^n$ using matlab, but since $n!$ and $n^n$ grows too fast as $n$ ...
user avatar
  • 2,034
0 votes
0 answers
37 views

Numerically solving a PDE in Matlab: Eikonal in an exponential formulation and initial/boundary conditions

I am currently working on a small research project as a part of my degree. The project is centered around Continuous-time Markov Chains, and based on this paper : https://hal.archives-ouvertes.fr/hal-...
user avatar
0 votes
0 answers
39 views

Crank Nicolson method error analysis

I am trying to solve the diffusion PDE: $$ \frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2}$$ using the CN discretization. I have implemented the method in Matlab, quiet ...
user avatar
0 votes
0 answers
10 views

How to remove "root(f(z), z, n)" from solve solution in MatLab

Wondering if it is possible to remove the expression "root(f(z), z, n)" from the solution presented by the solve function. In this case, my code is listed below and the outputs of "...
user avatar
0 votes
1 answer
30 views

How to find the value that give the global maximum of a function?

I have got the following function: $$L(x,y) = \frac{(16.2x +0.9y+5.2)^{24} e^{-(16.2x +0.9y+5.2)}}{24!} \cdot \frac{(2.1x +4.2y+0.9)^8 e^{-(2.1x +4.2y+0.9)}}{8!} \tag{1}$$ and I am attempting at ...
user avatar
  • 45
0 votes
0 answers
15 views

Lagrange multiplicator with discrete constraints converges to local minimum

I'm a Lagrange newbie, bear with me. I want to minimize $x^2+y^2$ subject to $x(x-1)(x+1) = 0$ and $y(y-1)(y+1)=0$. This problem has a single global minimum in (0,0). The Matlab code I wrote looks ...
user avatar
0 votes
3 answers
59 views

numerical solve equation with a list of parameter

I'm trying to numerically solve a equation like $$\exp(-A/x) + \exp(-B/x) = 1$$ there are two known lists of parameters $A=(A_1,A_2,...,A_n)$ and $B=(B_1,B_2,...,B_n)$, I hope to find a list of $x=(...
user avatar
  • 469
0 votes
1 answer
44 views

deval function in matlab

I can't understand how the deval function works in matlab, it's hard for me to understand the code, are there any books or descriptions of numerical methods where I can read about numerical algorithms,...
user avatar
  • 187
0 votes
0 answers
12 views

ANOVA design matric singular

I am working through the calculation for an ANOVA in MATLAB. I have noticed by definition, the design matrix with the intercept does not have full rank and the term inv(X' * X) is singular. Without ...
user avatar
  • 259
0 votes
0 answers
34 views

Numerical differentiation using forward difference method

I am trying to calculate the fourth derivative of order $O(h^2)$ and $O(h^4)$ of any function $f$, through the forward finite difference method, and which coefficients are given in this Wikipedia's ...
user avatar
0 votes
1 answer
44 views

Consistency in definition of Fast Fourier Transform

The book Numerical Analysis by Faires defines the fft of a signal $y_{j}$ as $$a_{k}+ib_{k}=\frac{(-1)^{k}}{m}c_{k}$$ where $$c_{k}=\sum_{j=0}^{2m-1}y_{j}e^{ik\pi j/m}$$ for each $k=0,1,...,2m-1$. How ...
user avatar

1
2 3 4 5
62