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
103 views

Linearized model of a nonlinear dynamic system

I have following dynamic system $$ \frac{\mathrm{d}v_C}{\mathrm{d}t} = -\frac{1}{R_b\cdot C}\cdot v_C\cdot\alpha, $$ where $v_C$ is the system state and output, $\alpha$ is the system input and $R_b, ...
Steve's user avatar
  • 303
0 votes
0 answers
13 views

How to make a scatter matrix of two vectors

Assume that you having two vectors $x \in \Re^n$ and $y \in \Re^n$ and you want to create matrix $X \in \Re^{n x n}$. The element of the matrix can be accessed from $X(i, j) = x_{x,j}$ coordinates, so ...
euraad's user avatar
  • 2,830
-1 votes
0 answers
53 views

A MATLAB loop programming problem

There is a function $f$ on integers. I want for all possibilities $a_1,a_2,\dots,a_{100}$ that are integers and satisfy $0\le a_{1}\le \dots\le a_{100}\le 15$, to compute and output $\sum_{k=1}^{100}f(...
Connor's user avatar
  • 1,821
1 vote
0 answers
27 views

How can I Find the stoichiometric coefficient of a complex chemical reaction??

I'm trying to balance a complex chemical reaction of decomposition of an organic material. I tried using Matlab to sole the set of equations I got, But the problem I get and where I think I'm missing ...
Ahmed Esaa's user avatar
-1 votes
1 answer
27 views

How to calculate orthogonal projection onto a feasible set of linear inequality constraint. [closed]

I need a Matlab code that can be used to project to a set $C$ defined as follows: 1). $C:=\{x \in \mathbb{R}^m: Bx \le d\},$ for some random matrix $B \in \mathbb{R}^{m \times k}$ and a random vector $...
Olawale Oyewole's user avatar
-2 votes
1 answer
68 views

Multiplication in Galois Fields using Matlab [duplicate]

I want to multiply two elements of $GF(2^4)$ with $P(x)=x^4+x+1$ being the irreducible polynomial. I know how it is done on paper, for example: $$(0110).(1000)=(x^2+x).(x^3)=x^5+x^4=x^4(x+1)=(x+1)^2=x^...
Mohammadsadeq Borjiyan's user avatar
1 vote
1 answer
30 views

How to add new rows into a matrix $X$ without change its center?

Assume that you have a matrix $X \in \Re^{m \times n}$ and you have centered it column wise. $$\mu_j = \frac{1}{m}\sum_{i=1}^{m} X_{i,j}$$ $$X = X - \mu_j$$ MATLAB code: ...
euraad's user avatar
  • 2,830
1 vote
1 answer
73 views

Generating random quadratic and linear programming optimization problems

I have coded two solvers (interior-point and active set algorithms) of quadratic problems of the form: $$ \min_x \quad f(x) = \frac{1}{2} x' H x + g' x $$ $$ s.t. \ \ A' x = b $$ $$ \qquad \quad \ \ ...
Bergson's user avatar
  • 1,627
1 vote
0 answers
20 views

Circular integration using trapz in matlab

I want to solve an integral that is of a following form in Matlab: $\int_{r}\int_{t} r e^{i * (F(r,t)x + G(r,t)y + H(r,t)z)} drdt$ I used to be able to find a surface fit in matlab for the F, G, and H ...
Lernj's user avatar
  • 21
0 votes
0 answers
21 views

How can I compute the null vector using QR factorization?

Assume that you have a matrix $X$ and you want to compute the complex eigenvectors. You only know the complex eigenvalues. With that information, you could solve the null space formula $$(A-\lambda I)...
euraad's user avatar
  • 2,830
1 vote
1 answer
62 views

Numerical integration improves when step size is smaller, but in which direction?

I am implementing a double integration of a function; numerically in Matlab. What I basically do is: ...
Neelabh Jyoti Saharia's user avatar
0 votes
1 answer
51 views

What's the best way to make a symmetric matrix positive definite?

Assume that you have a matrix $X \in \mathbb R^{m \times m}$ and it's symmetric, but it's not positive definite. What's the best way to turn the matrix $X$ into a positive definite matrix? I have a ...
euraad's user avatar
  • 2,830
0 votes
1 answer
42 views

How to vectorize a function that accepts a matrix and returns a vector in Matlab/octave/python

Given a function, that accepts a matrix and returns a vector: $g(X):\mathbb{R}^{nxm}\rightarrow \mathbb{R}^{m}$, s.t. $g^{(i)} = t\cdot X^{(i)}$; where $X$ is an $n\times m$ matrix, $t$ is a row ...
Lis_IO's user avatar
  • 3
0 votes
0 answers
38 views

Finite linear quadratic tracking problem using Matlab

I'm trying to solve the following linear quadratic tracking problem using Matlab. The dynamics: $\dot{x}(t) = Ax+Bu$ (scalar system) The objective function: $J=\frac{1}{2}x(t_{f})^{2}+\frac{1}{2}\int_{...
Sam's user avatar
  • 1
0 votes
0 answers
19 views

Need help in projected area of pipe along the direction of flow

I have modeled pipe and elbow using MATLAB (Fig. 1). Have some confusion how to calculate the projected area of the element of pipe and elbow. For instance, if water is flowing in Z direction, ...
Manik Mia's user avatar
0 votes
0 answers
21 views

How can I use the finite difference method to solve a simple unconstrained optimal control problem?

I want to solve this problem using finite difference method. \begin{equation} \begin{cases} &\min_{y, u} \quad \mathcal{J} = \frac{1}{2}\left\lVert y-z \right\rVert^{2} + \frac{\alpha}...
wc x's user avatar
  • 1
0 votes
0 answers
47 views

non-linear system of ordinary differential equation

I have the following system of equations and aim to solve it analytically. My main problem is MATLAB code or function(s) to solve it. Any one can help me? ($$a_i, b_i, c_i$$ and $$d_i$$ are known ...
Mahmood Dadkhah's user avatar
0 votes
0 answers
29 views

MATLAB for nonlinear algebraic equations solvers or numerical methods

Which gives much better results while solving system of non linear algebraic equations, fsolve or any other numerical method for example Newton's method? Can you suggest other numerical methods for ...
Understanding things's user avatar
0 votes
0 answers
25 views

Plotting the 3D Heat Equation in 2D Slices

I am trying to plot the temperature distribution of a cake using the heat equation in 3D in MATLAB. The boundary conditions are . I am trying to plot the temperature distribution of a cake shaped as a ...
Orkiel's user avatar
  • 11
0 votes
0 answers
24 views

Parabolic PDEs: is it possible to simulate blow-up phenomena in MATLAB?

I want to learn to use matlab to study the graphical behavior of parabolic partial differential equation solutions, in the sense of trying to simulate when the solution will be global or when it will ...
Ilovemath's user avatar
  • 2,815
0 votes
0 answers
48 views

Delay Differential Equations System of equations

I need some help with Confirmation my system of equations truly is a DDE system and Any insight into users who have solved state dependent DDE systems (either using matlab ddesd or could recommend a ...
spacegirl1923's user avatar
1 vote
0 answers
10 views

How to plot an m-refinable function

I have a $\mathcal{C}^0(\mathbb{R})$ given implicitly as $\varphi(x)=\sum\limits_{k=-3}^{k=3}a_k\varphi(3x-k-\frac{1}{2})$, and I know the coefficients $a_k$ and the values of $\varphi$ in the points $...
AndreaBaleani's user avatar
0 votes
0 answers
16 views

Helmholtz FFT solver for 2D fluid simulations in MATLAB

I am performing a 2D fluid simulation in vorticity-streamfunction formulation and instead of a Poisson equation at each time step I need to solve an inhomogeneous Helmholtz equation of the form $$\...
SpaceChild's user avatar
0 votes
0 answers
35 views

Showing the convergence rate of theta method

I'm trying to apply the theta method to the 2D heat transfer equation: $$\partial_t u -\Delta u = f$$ With a second order discretization in space. Now, I was able to show 2nd order in space by keeping ...
Matt's user avatar
  • 1
1 vote
1 answer
22 views

Given the length of the interval and some constraints, how to use MATLAB to output the expression of the interval's starting point about the length

Now I have a serrate function f(x) with a minimal positive period $T=2$ (slope $k=1$ when $nT <t \le nT+T/2$ ; $k=-1$ when $nT+T/2<t \le nT+T$) Here's the plot: Given a data x, try to determine ...
Дъартский's user avatar
0 votes
0 answers
38 views

How to plot a piecewise function on Matlab?

I am unable to plot this graph. Any one please help me to plot? ...
Amna Habib's user avatar
0 votes
0 answers
19 views

How to determine the value of 𝑘 in a linear equation system to ensure that the sum of all columns in a matrix is less than 1?

I was wondering if anyone could help me out with an assignment. It's related to linear equation systems, and I need to fill in some code and answer a few questions. The part I'm currently stuck on ...
Bishop_1's user avatar
  • 335
1 vote
1 answer
45 views

Computational efficient way to compute/generate a matrix and a "row-wise" matrix product

Given a fixed vector ${\bf x} = (x_1, x_2, \ldots, x_N) \in \mathbb{R}^N$, I am wondering if someone has a good idea on how to generate (in Matlab, the version I am using currently is R2022b) the ...
Fei Cao's user avatar
  • 2,622
0 votes
0 answers
30 views

MATLAB not displaying the required output.

I am trying to solve a problem by optimizing it using a linear programming algorithm. I am using the algorithm in which I am minimizing the objective function: $$ c^T x$$ subjected ...
Muhammad Ahmad's user avatar
3 votes
2 answers
83 views

Why plot of a sinusoid with a large phase appears like a staircase?

I plotted the following in MATLAB and Desmos: y = cos(x + 6998666554443343) (1) The plot is shown here: Plot of (1) This staircase behaviour seems to appear with ...
Manvendra Sharma's user avatar
1 vote
0 answers
30 views

Simulating Derived State Space Matlab

I've derived a state space system, where each equation had a constant term at the end. As far as I'm aware in order to perform state space analysis I should combine them into Bu like this (sorry not ...
Lachlan M's user avatar
0 votes
0 answers
28 views

Plotting a curve on MatLab

I asked the same exact question in Stack Overflow but I'm afraid it could be OT therefore I'm asking it also here. I was wondering on how I could plot this curve $\left(x_3(t)-\frac{1}{\omega^2b}\...
dodo's user avatar
  • 75
0 votes
0 answers
27 views

Constraints using the discrete Poisson's problem for Constrained Optimization

I am working on Constrained Optimization, using the Penalty Method, and then using Uzawa's algorithm. I am looking to minimize the objective function f, given by ...
Charbel Nicolas's user avatar
0 votes
1 answer
61 views

Solving 1D Boundary Value Problem using Discrete Fourier Transform. I am trying to solve it in Matlab, where did I mess up?

I have a basic steady-state Boundary Value Problem (BVP) that I am trying to solve discretely by using Fourier Transforms. The setup is such that: $$\cases{u(x_i)_{xx} = f(x_i),f(x_i) = 2, & $x\in ...
Researcher R's user avatar
1 vote
1 answer
88 views

How can I numerically obtain the eigenvalues of the second-order derivative from the discretization matrix?

I want to find the eigenvalues of the second-order derivative (with pure Neumann boundary conditions, on the interval $[0,1]$) numerically and compare them with the eigenvalues derived analytically. ...
Ivan K.'s user avatar
  • 21
0 votes
0 answers
22 views

Calculate a lower bound for the condition number κ(A) for the matrix A.

We have a matrix A for which we want to give an estimate of the condition number. We know that the system Ax = b with input b = (4, −8, 1)T has solution x = (2, 1, 0)T We also know that a somewhat ...
Sandra's user avatar
  • 1
0 votes
0 answers
18 views

Why does Newton-Raphson method oscillate between two values [duplicate]

If I use starting value x0 = 1 for the following function Newton-Raphson oscillates between -0.113356775 and 0.113356775. If I however use other values, I manage to find the root. Why is that? Any ...
LLScheme's user avatar
0 votes
1 answer
46 views

The frequency from FFT given sample rate

I have a dataset with some data that's recorded daily. I have a strong sinusoidal trend I want to extract using FFT in MATLAB. However, I don't exactly get what it is I'm seeing. The frequency output ...
William Brochmann's user avatar
0 votes
1 answer
52 views

Laplace transfer tunction for filter equivalent to Matlab 2nd order butterworth filter [closed]

I am trying to build a bandpass filter analytically with the following specification: Center frequency of fc (say $16Hz$) Pass bandwidth of fb (say 2hz. therefore, cut-off frequencies are $15$ and $...
EricH's user avatar
  • 3
0 votes
2 answers
50 views

Why does my implementation of the galerkin method yield the correct values, but with inverted sign

I tried to implement the galerkin-method for the one dimensional poisson equation. I chose for the boundary conditions $$ u(0) = u(1) = 0 $$ and for the "source" term $f(x)$ $$ \frac{\...
Matthias Friedel's user avatar
0 votes
0 answers
57 views

Solving second order differential equation for Bridge using numerical methods in matlab

Working on the following problem: We have an arch bridge with length 204 meters and a max height to the water of 26 meters. The symmetrical Arch is described by the second order differential equation $...
Sweauz 's user avatar
0 votes
0 answers
82 views

Implementing Finite Differences solver for 2D Poisson Equation

I'm trying to solve the 2D Poisson equation: $$ \begin{cases} -\Delta u = f & \text{in} \hspace{0.2cm} \Omega=(0,1)^{2} \\ g = u & \text{on} \hspace{0.2cm}\partial \Omega \end{cases} $$ Using ...
voyseto's user avatar
  • 11
0 votes
0 answers
61 views

Convert the PDE into divergence form

I'm trying to use MATLAB's PDE solver to solve the following PDE $$ (-Lx + \gamma y^2 - F)u_x +(-Sy - \gamma xy)u_y + \sigma^2 u_{yy} = -1 $$ $$ L, \gamma, F, S, \sigma^2 \in R $$ I need to put this ...
MJ33's user avatar
  • 95
0 votes
1 answer
63 views

How can I calculate the limit of sequence using MATLAB?

Using MATLAB I want to calculate the limit of the sequence below. $$ a(n)=\frac{n^2+1}{3n^2+1} $$ $$ \lim_{(n\to\infty)}a(n)=? $$ At first I thought \ syms n a(n)=(n^2+1)/(3*n^2+1); limit(a(n),'n',...
Cashman's user avatar
  • 43
0 votes
0 answers
26 views

Identify the coefficients of each constraint separately.

I have 4 restrictions below. I would like to make an array of coefficients for each constraint separately. I did the first two, I would like to know if it is correct, first, and I would like help to ...
Carlo Soares's user avatar
0 votes
0 answers
48 views

Discrete vs. continuous Fourier transform for a continuous time process

my objective is to prove why we can't use fft (which uses DFT) to calculate the PSD on a continuous time process. The teacher instractures word by word are: go to Matlab and read help on fft(), copy ...
Or Perez's user avatar
0 votes
0 answers
20 views

What is the right way of placing coupled terms when writing a non-linear coupled differential equation in matrix form?

I have a system of non-linear differential equations (6DoF equations of motion) that I'm trying to solve with Matlab using the Ringe-Kutta method. For this, I'm trying to write the equations in matrix ...
Jake Stravinsky's user avatar
1 vote
0 answers
63 views

Finite Difference Methods for 1D Transport Equation with Larger Stencil Widths

I'm attempting to re-create the numerical experiments in this paper for solving the 1D scalar advection (transport) equation$:$ $$ \frac{\partial u}{\partial t} + \frac{\partial u}{\partial x} = 0 $$ ...
voyseto's user avatar
  • 11
0 votes
0 answers
40 views

How to mathematically model in MATLAB?

I am trying to create a code for the following statement in MATLAB: Suppose there are 60 small base stations (small mobile towers) and 1 Macro base station (big mobile tower). Let us index these nodes ...
Heretolearn's user avatar
2 votes
0 answers
89 views

PI Controller - Integral term is causing instability

I am simulating the height of the reservoir in a hydro power plant using Matlab, without Simulink. The radial gates of the power plant are used to control the height of the water in the reservoir. ...
Grétar Már's user avatar

1
2 3 4 5
63