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
0answers
11 views

MATLAB program for convolution

MATLAB program for $\sum\limits_{m = 1}^\infty {\left( {\frac{{{f_1}\left( t \right){t^{m - 1}}}}{{(m - 1)!}} + \frac{{{\gamma _2}{f_2}\left( t \right){t^m}}}{{m!}}} \right){{\left( {\frac{\lambda }{\...
-2
votes
1answer
35 views

MATLAB coding for convolution of two functions [closed]

If $f(t)=e^{-at} \,$ and $\, g(t)=e^{-bt}$, what is the MATLAB code for finding the convolution of these two functions, i.e. $(f*g)(t)=\int\limits_0^t {{e^{ - au}}} {e^{ - b(t - u)}}du$?
0
votes
0answers
13 views

How to assess if a line segment crosses the volume of a tetrahedron in MATLAB

I have a tetrahedral mesh and a set of line segments. I want to be able to find out if and where each of these line segments cross the tetrahedra of my mesh. I found some answers such as this thread: ...
0
votes
0answers
13 views

How to write MATLAB code to find the answer of the equation with given all values of its variables?

I'm practicing MATLAB. and I stuck with this problem. Suppose I have Equation in general form like this $d = ab + AB^2 + abB$ I have all values of its variable $a = 1 , b=2, A=4 ,B=6$ How to write ...
2
votes
2answers
84 views
+50

(MATLAB/Python) Euclidean projection on the simplex: why is my code wrong?

I'm trying to implement the algorithm for Euclidean projection onto the probability simplex in, https://eng.ucmerced.edu/people/wwang5/papers/SimplexProj.pdf which is widely cited and I presume to be ...
0
votes
0answers
38 views

Evaluating a double contour integral in MATLAB or Python

How to evaluate the following bivariate Fox's H function in MATLAB or Python $$ H\left[x,y\right]= -\frac{1}{4\pi^2}\int_{L_1}\int_{L_2}{\phi_1\left(\xi, \eta\right) \theta_2\left(\xi\right)\theta_3\...
0
votes
0answers
30 views

interpolation of convolved function

I want to numerically calculate the convolution of two functions, eg. $$F(\omega) = \dfrac{b}{(\omega-a)^2+b^2}, \quad G(\omega) = \dfrac{d}{(\omega-c)^2+d^2}$$ Convolutions are by definition $(F * G)(...
0
votes
0answers
15 views

Numerical solving of a nonlinear ODE with boundary condition for free surface deflection

I am trying to solve a nonlinear 2nd order ODE that is used for free surface deflection of fluid under gravity, pressure, and surface tension influences. The ODE is given as follows $\rho g\varphi + {...
-1
votes
0answers
13 views

How to find a nonlinear model (potentially nonlinear) from multiple input variables to one response output?

I have a big data set $X=[x_1, x_2 ... x_{200}]\in \mathbb{R}^{n \times 200}$, and $y\in\mathbb{R}^n$ where $n$ is the observation numbers, and $x_1, x_2 ... x_{200}$ are input variables. How to find ...
0
votes
1answer
31 views

How to create line with 6th order spline?

I am dealing with spline interpolation and what I do is basically interpolating $6$th order ($7$ control points) spline through some discrete points. Curve-based part of my algorithm is done, however, ...
0
votes
0answers
16 views

finding one Special realization in matlab

I want to find realization for a system like below how can I do that in matlab.
-1
votes
1answer
30 views

I am trying to solve a non-linear equation. In the matlab program, I'm stuck up.

One of the problems could be that, I want a matrix of order 33 but the output is 44, with first row and first column consisting of zeros. Can someone help ! n=5; m=5; T=1; for i=2:n-1 for q=2:m-1 ...
1
vote
0answers
38 views

Solving coupled integral equations

I would like to solve coupled integral equations of following form: $$ \begin{cases} f(0,n) = 1 + \displaystyle\int\limits_{0}^{\infty} K(n,p)f(1,p)dp \\ f(1,n) = g(n) + \displaystyle\int\limits_{0}^{...
0
votes
2answers
52 views

How to write these function with disciplined convex programming rule to use CVX? x*(2^(y/x)-1)

I have the following functions in an optimization problem. $x\times 2^{(y/x)-1}$ $ x \log (a+b\times 2^{(y/cx)-1} )$ Here, x,y>0, and also a,b,c>0, and b>a. For these conditions, I checked ...
0
votes
0answers
30 views

Determining a relationship in statistical data [migrated]

I have a large set of data that models the average number of days it takes for people to re-lease a house of type $i$. I have created an example via Matlab below using random data to help illustrate ...
0
votes
0answers
18 views

Using Matlab to calculate numerically the jacobian of a vector-valued function

I would like to use numerical methods to calculate the Jacobian of a vector-valued function in Matlab. Matlab has function for this, called jacobianest The equation that I am working with requires ...
0
votes
0answers
12 views

Retrieve every step solution with linprog interior point

I need to get the every step solution of the interior point algorithm implemented in linprog, but I do not succed to. In fmincon, that is another solver, it is possible with output function, but in ...
0
votes
0answers
23 views

Weights in Markowitz portfolio[Matlab]

Hello everyone I read article about Plotting an Efficient Frontier Using portopt. https://www.mathworks.com/help/finance/plotting-an-efficient-frontier-using-portopt.html?fbclid=...
0
votes
0answers
12 views

Discretization of inhomogeneous Dirichlet boundary conditions for 2D heat equation

We have the following PDE on $\Omega = [0,1] \times [0,1]$: \begin{equation} \begin{split} \partial_t u &= \Delta u \; \; \text{for} \; \; (x,y) \in \Omega \\ u &= -1 \; \; \text{on} \; \; \...
0
votes
1answer
33 views

Draw plane via 3 points

I have 3 points (1,1,1), (2,2,2), (2,2,0). It is enough to draw plane via these 3 points. But how to do this in Matlab? I'm planning to use surf() function. I do: <...
0
votes
0answers
11 views

Matlab program for Rayleigh wave

Respected all members, can any one provide me Matlab program for Rayleigh wave propagation in any medium. Please mention the paper also containing that program
0
votes
2answers
39 views

How can I minimize a quadratic over a $2$-norm ball in Matlab?

On Matlab, how can I solve $$\begin{array}{ll} \text{minimize} & x^tQx + b^tx + c\\ \text{subject to} & \|x\|_2 \leq C\end{array}$$ where $C > 0$? I read about function ...
0
votes
1answer
24 views

Saving nodes in iterative Adaptive Simpson quadrature method (Matlab)

Implementing on Matlab the Simpson adaptive rule to approximate an integral (the following code), I am struggling with saving nodes correctly. I have tried different solutions, but none of them seems ...
0
votes
0answers
14 views

Reshaping Arrays

(Select all that apply) Which syntax creates A? A = 5 1 1 1 7 6 Image Hint: Data is dealt out column-wise. But, matrices are created row-wise.
0
votes
0answers
16 views

I'm having trouble plotting the following qcd function

: $$C(t)=\frac{1}{3}\frac{1}{L^3}\sum_p \frac{p^2}{E_p}e^{-2E_pt}$$ So basically what I'm trying to do is use matlab to plot this function against time. In this case p is 3 momenta vector such that: $$...
0
votes
1answer
23 views

How to enforce a preference for a flat linear programming solution

I'm trying to solve a convex linear programming problem related to charging and discharging a battery. In general (for my problem), charging the battery at low power over a long period has the same ...
1
vote
0answers
18 views

Convert a 3D Matlab .fig to a rotatable 3D PDF

I'm trying to convert a 3D MATLAB plot to a rotatable PDF file (so the figure can be spun around and interacted with without MATLAB software for illustration purposes). I have used this function https:...
0
votes
1answer
51 views

DCT using FFT results in complex result

I'm trying to implement a DCT10 accourding to this paper https://www.researchgate.net/publication/330405662_PittPack_Open-Source_FFT-Based_Poisson%27s_Equation_Solver_for_Computing_With_Accelerators (...
0
votes
0answers
15 views

Calculate the difference between two fft's

I have a time-series of length N generated by the following equation: ...
0
votes
1answer
14 views

Plotting function g(v) against p(v)

I have a function g(v) which is Gibbs free energy and another function which is p(v) which is described by Vanderwaal's model. Anyway I need to plot g as a function of v but I am unsure of how to do ...
0
votes
0answers
15 views

Evaluation of associated Legendre function of the first kind with complex arguments

I am trying to evaluate in Matlab an expression involving the associated Legendre function of the first kind $P_\nu^\mu(z)$. If my understanding is correct, this function has two slightly different ...
1
vote
1answer
97 views

Creating a “Swiss Torus” using

I have the following matlab code that generates a "Swiss Roll": ...
0
votes
0answers
12 views

FDTD method with central difference scheme

I have a question related to central difference scheme in 1D-FDTD program. In this program, I want to simulate the Gaussian pulse propagation in silicom waveguide. The problem I am facing here is that ...
0
votes
0answers
34 views

Gauss-Lobatto and Gauss-Laguerre quadrature

I'm using MATLAB and this function: ...
1
vote
1answer
34 views

Derivative after parameter - system of ode

\begin{align} \frac{dx_{1}}{dt}& = x_{2} \\ \frac{dx_{2}}{dt} &= - A x_{1} - B x_{2} + a\sin(Ct) \end{align} $x_{1}(0)=1$ and $x_{2}(0)=0$ I want to draw 2 plots in Matlab: $\frac{dx_{1}}{dA}...
0
votes
0answers
14 views

How can I tell if a simualtion of a spherical wave equation implements damping?

In this link you can see the following simulation of a spherical wave: The MATLAB code is provided here. ...
0
votes
2answers
18 views

MATLAB elementwise matrix element access with ndgrid.

(Apologies if this is the wrong SE) I've got a function containing a rather ugly nested for loop structure that I'm trying to vectorize. Effectively, I've got a matrix of coefficients, C (as a ...
0
votes
0answers
7 views

How do I implement a simulation of a damped 3 dimensional spherical wave in MATLAB?

From this link I was able to successfully implement a damped wave. I used MATLAB's movie command to send it frames (or snapshots) of the current values of the wave over time. Here is the MATLAB ...
2
votes
1answer
70 views

Calculate the number of triplets in a graph

I try to compute the global clustering coefficient of a graph in Matlab using the adjacency matrix. I know how to find the number of closed triangles: ...
1
vote
1answer
20 views

Find other two orthogonal vectors based on one direction and other constrains

In order to define a coordinate system I need 3 vectors, one for each axis. Constrains: Z axis: known. X axis: z == 0. It is on XY plane. Y axis: z < 0. How can I find X and Y axis? A Matlab ...
0
votes
0answers
21 views

Optimization solver, Rotation Matrix

As a part of my work I want to find a transformation matrix from Frame A to Frame B. Let us define Frame A axis ($X_a,Y_a,Z_a$ - all are orthogonal to each other) Frame B axis ($X_b,Y_b,Z_b$ - all ...
0
votes
2answers
19 views

solving quadratic equation in motion equations

Is it possible to solve this equation for $t$ $$x_f = x_0 + v_0t + \tfrac{1}{2}at^2~?$$ It feels like its a quadratic but since x final and initial are not the same and sometimes initial is not ...
1
vote
1answer
40 views

Problems with quadratures

I'm having issues when computing quadrature, and probably there is something I do not get theoretically. I looked everywhere, but no one seems to explain in a good way the problem I have a simple ...
0
votes
0answers
19 views

How can I evaluate the arg min/argmin of a sequence in Simulink/real-time?

I am wondering whether someone could give me some hints on how to evaluate/implement the math function arg min/argmin in Simulink. Let's say that I have the following expression $$ \hat{y_{16}}:\...
0
votes
1answer
18 views

Generating a random vector of a given norm in Matlab

I need to create a random vector $v$ of size $n$ with the condition that $\|v\|_1 = 10^{-8}$. I was thinking of creating it like v = rand(n, 1) * 10e-8, but it does ...
0
votes
0answers
14 views

How do I find the asymptotic fit of 2 vectors

My vectors are r=[5.7 9.4 12.9 15 17.6 20.6 24.4 26.9 29.7 33.9] and n=[32.99 7.81 4.79 3.4 2.72 1.84 1.48 1.16 0.84 0.72] and ...
0
votes
1answer
32 views

Find the Laurent series at z=0

Find the laurent series expansion of $\frac{1}{z(z+5)}$ at z=0. I found the solution for this question in MATLAB. The solution I got was $\frac{5}{z}+1$. I don't understand how the laurent series is ...
0
votes
1answer
45 views

Something is wrong with my MatLab 2nd Order ODE solver, and I can't figure out what it is.

I'm trying to do one of MIT's Computational Methods in Aerospace Engineering projects. I've written the code for Project #1 part 1, and I'm getting a very reasonable solution using the euler, midpoint,...
1
vote
0answers
26 views

Compute rotation matrix from fitting a plane with its own coordinate system

I'm trying to find rotation matrix for a plane from given 4 points $X_1 ... X_4$ that form a square. These points are fixed on a rigid square that can take any position in world coordinate system. I ...
0
votes
0answers
10 views

Plot channel vs error probability

How to give relation between channel vs error probability .with the given marginal probability and to Comment on result based on finding. How to approach this question? Can someone please help?

1
2 3 4 5
57