Articles of matlab

Solving a Convex Optimization Problem Using a/any Programming Language

I have the following convex optimization problem: $$\begin{array}{ll} \text{maximize}_{{f,g}} & \displaystyle\int_{\mathbb{R}} g^u{f}^{1-u}\mathrm{d}\mu\\ \text{subject to} & \displaystyle\int_{\mathbb{R}} f \mathrm{d}\mu= 1,\quad \displaystyle\int_{\mathbb{R}} g\mathrm{d}\mu =1 \\ & f_L \leq {f} \leq f_U\\ & g_L \leq g \leq g_U\end{array}$$ where $u\in(0,1) $ and $$\int_{\mathbb{R}}f_L \mathrm{d}\mu< 1,\quad\int_{\mathbb{R}}g_L \mathrm{d}\mu< 1$$ $$\int_{\mathbb{R}}f_U \mathrm{d}\mu> 1,\quad\int_{\mathbb{R}}g_U \mathrm{d}\mu> 1$$ Here, $f$ and $g$ are distinct […]

Classic 10 Balls into 4 boxes problem

Question:Throw at random 10 balls into 4 boxes. What is the probability that exactly 2 boxes remain empty? My Solution: Using the stars and bars method, the boxes and balls can be thought as $0$ and | e.g. one configuration would be $$ 000000|00|0|0 $$ which would represent 6 balls in the first box etc. […]

why does matlab give me a negative number?

I have the following problem A steel company has four different types of scrap metal (called Typ-1 to Typ-4) with the following compositions per unit of volume They need to determine the volumes to blend from each type of scrap metal so that the resulting mixture has the following amounts of Al, Si, C, and […]

Algebraic Riccati equation (DARE) stabilazability condition

I’m Trying to help in this question which involves Algebraic Ricatti equation. Honestly to say I never met this equation before. I’m struggling to understand the conditions stated in the limitations of the dare algorithm in matlab. For convinience I quote it here: The $(A, B)$ pair must be stabilizable (that is, all eigenvalues of […]

Lagrange polynomial and derivative problem

I need to code this function in matlab $$L'(x) = \sum_{k = 0}^{n} f_k l_k(x) $$ Where’s $l_k$ looks like this $$l_k(x) = \sum^{n}_{j=0, j \neq k} \frac{\prod^{n}_{i=0}(x – x_i)}{(x – x_k)(x-x_j)\prod^{n}_{i=0, i \neq k} (x_k – x_i)} $$ Well I got an array of $f_k, k = 1,\dots,n$ (there are results of error function […]

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 thing, my first thought is to find the angle between each (normalized) quaternion, and then find the RMS of that […]

Normality test vs. Fitting a Gaussian curve

I have a set of one-dimensional data, and I suspect that the data is normally distributed. Before embarking in a normality test, I decided to fit a Gaussian curve to the histogram of relative frequencies, and see how well it fits. The result can be seen in the following image: In my opinion it fits […]

is there a name for this function (parity of a finite sequence)?

Variants of this question have been crossposted to Stack Overflow and Computational Science Stack Exchange. Additional answers may be found at these other sites. Math people: In an attempt to solve a larger problem, I defined a function $\sigma$ as follows: if $(x_1, x_2, \ldots, x_n)$ is a finite sequence of distinct real numbers, then […]

Let $\sum_{n=1}^\infty \frac{a_n}{3^n}.$ Determine (numerically or not) the limit of the infinite series by choosing $a_n=0$ or $2$ randomly.

The problem I have is essentially in the title. What I’m trying to do in Matlab is to have a set which has two elements $0$ and $2$ and to choose either $0$ or $2$ randomly and plug it into the series at some $n$. To just generate either $0$ or $2$ I’ve used the […]

MATLAB, 1st order 2d hyperbolic equation, problem with convergence.

Follow up to my previous question: MATLAB: solving 1st order hyperbolic equation in 2 spacial dimensions The equation I’m solving has the form: $$f_t + A y f_x – B x f_y =0$$ I wrote the following code according to the comments from the previous question: % Liouville equation clear; % Equation Parameters: Xmin = […]