MATLAB is a high-level language and interactive programming environment for numerical computation and visualization developed by MathWorks. MATLAB can be used when performing tasks such as signal processing and communications, image and video processing, computational finance, and computational ...

learn more… | top users | synonyms

2
votes
0answers
250 views

Math notation for expressions using logical (binary) masks on images (matrix)

I need to write up what I have written in matlab: I have an image (that is, a matrix) $K$ and some other matrix of the same size $M$ which acts as a mask which represents the values I would like to ...
2
votes
1answer
79 views

improving symbolic generation of objective function for optimization

I am currently using matlab to solve an optimization problem. I am generating the objective function using the symbolic toolbox. I planned use the symbolic toolbox to calculate the gradient and ...
2
votes
1answer
175 views

Creating an ellipsoidal 3D surface

I am trying to find the equation of a 3D ellipsoidal surface. I have thought of two approaches which are schematically shown below: By revolving an elliptical arc over a 3D elliptical path: Or by ...
1
vote
1answer
2k views

MATLAB curve fitting - least squares method - wrong “fit” using high degrees

Anyone here that could help me with the following problem? The following code calculates the best polynomial fit to a given data-set, that is; a polynomial of a specified degree. Unfortunately, ...
1
vote
1answer
31 views

Compute $\left(a_{i}A+B\right)^{-1},\qquad i=1,\ldots,N$ efficiently?

I need to compute the inverse matrix: $$(a_i A+B)^{-1}, \qquad i=1,\ldots,N$$ where $N$ is a large number. $A$ and $B$ are general $M\times M$ matrices independent of $i$. The only thing that ...
0
votes
1answer
188 views

How to define a meshgrid (x,y) between the intersection of two oblique lines.

How can I create a meshgrid to draw a 3d surface in a domain (zone 1) defined by the intersection of two oblique lines in Matlab (see attached figure)1. The variables 0
2
votes
0answers
98 views

how to use Matlab ifft to calculate the following integral? [duplicate]

$$R(t)=\int_{-\infty}^\infty\dfrac{\omega e^{i\omega t}}{(3-\omega^2)^{2}+4\omega^2}\,d\omega$$ where t is a integer and $t>0$ I used to calculate this integral by numerical integral,but it seems ...
0
votes
2answers
493 views

How to use Monte Carlo method to find volume?

So the question asks to use the Monte Carlo method to find the volume of an irregular figure defined as: ...
0
votes
1answer
61 views

Matrix Factorization of lower triangular and unit upper triangular.

So I have a matrix. $$A =\begin{bmatrix} 8 && -3 && 2 && -1\\ -3 && 8 && 0 && 2\\ 2 && 0 && 8 && -3\\ -...
2
votes
1answer
332 views

Gauss quadrature on tetrahedron

I have the Weights ${\bf w}=[w_1\,w_2\, w_3\, w_4]=[0.25, 0.25, 0.25, 0.25]/6$ and the points ${\bf x_1}=[0.1381966011250105 , 0.1381966011250105 , 0.1381966011250105]$ ${\bf x_2}=[0....
0
votes
0answers
33 views

Guassian quadrature

Consider the polynomial $L \in P_5$ defined by $$L(x)=\frac{d}{dx^3}(1-x^2)^4$$ My question is to use a technique similar to the one used in the analysis of the Gaussian quadrature to show that Q has ...
1
vote
1answer
34 views

Replaces data in a matrix with Matlab

A is a matrix (6 ×6) defined as: A= [0.25 0.35 0.46 0.56 0.67 0.78; 0.25 0.37 0.49 0.61 0.73 0.86; 0.25 0.38 0.52 0.66 1.80 1.94; 0.25 0.40 ...
0
votes
1answer
72 views

MINLP optimization with matlab reaching different solutions every run

I have written a program for optimizing a set of generators. I have hourly price and cost data and need to figure out when a generator should run or just stay off. I describe the problem in more ...
0
votes
1answer
168 views

matlab MINLP optimization with ga

I have written a program for optimizing a set of generators. I have hourly price and cost data and need to figure out when a generator should run or just stay off. There are additional constraints but ...
0
votes
1answer
211 views

integer linear programing in matlab with the symbolic toolbox

I am writing a program to optimize a set of generators. I have hourly data and but dont want to necessarily optimize the whole time series. For a similar problem in the past I used the symbolic ...
1
vote
1answer
896 views

Matlab simulation of dog chasing a rabbit pursuit curve.

Hi I'm really struggling with this problem of mine. A rabbit is running along the x-axis (0->∞) with a constant velocity vr and a dog chases the rabbit starting at some point L (0...∞) on the y-axis ...
1
vote
0answers
84 views

Matlab Newton's Method Non-linear system

There is something wrong with this program and I cannot seem to find it. I am trying to calculate the solution of a non-linear system using Newton's method. Matlab keeps saying there is a problem with ...
2
votes
3answers
52 views

MATLAB: matrix multiplication with exponentiation

Normal matrix multiplication computes $C=A*B$, such that $C_{ij}=\sum_k{A_{ik}*B_{kj}}$ I want to compute D, such that $D_{ij}=\sum_k{e^{A_{ik}*B_{kj}}}$ Basically I want to exponentiate each ...
0
votes
2answers
9 views

Generating points from bi variate normal mixture densities

I am asked to generate 200 and 1000 points from a bi-variate normal mixture densities. I am trying to understand the algorithm, not just the matlab code (I have to write it, not use an existing ...
1
vote
1answer
365 views

plotting cone on matlab

Plot the portion of the cone $z=sqrt((x − 1)^2 + y^2)$ inside the cylinder $r = 2$ This is my matlab code. However, I get an error with the ezsurf line. Any ideas as to what I might be doing wrong? ...
0
votes
3answers
1k views

determine unit outward normal vector on a curve

It is necessary for me to find unit outward normal vector for the curve: $$\gamma=(x(t),y(t))$$ where $$x(t)=(0.6)\cos(t)-(0.3)\cos(3t)$$ and $$y(t)=(0.7)\sin(t)+(0.07)\sin(7t)+(0.1)\sin(3t)$$ I ...
0
votes
1answer
187 views

Incomplete Cholesky decomposition conjugate gradient method in Matlab

I have a problem in finding the numerical material that describing in detail for incomplete Cholesky combined with conjugate gradient method by using Matlab. Someone can help me? Many thank in advance....
1
vote
1answer
66 views

Matlab solution for non-homogenous heat equation using finite differences

Given the following PDE (non-homogenous heat equation): $$ u_t(x,t) = c^2u_{xx}(x,t) + f(x,t) $$ $$ u(0,t) = u(l,t) = 0 $$ $$ u(x,0) = g(x) $$ $$ 0 < x < l ; t > 0 ; c > 0 $$ I wrote the ...
0
votes
1answer
76 views

Matlab Recursion Loop

I need to create a loop to answer part c of the following linear algebra question. I'm new to Matlab so this is extremely confusing. I'm not sure how to make a loop that "counts" from 0-25 in order to ...
1
vote
1answer
66 views

Least Squares in Matlab

I'm stuck on part (d) I'm not sure how to code it so that it approximates that function in matlab. I'm also not sure if my (a) thru (c) are correct. But this is what I have so far. ...
0
votes
2answers
42 views

Matlab code for creating matrix

I have a problem, I am working with numerical approximations. Now i have $-1=x_0<x_1 <...<x_n=1$ with $x_i=x_{i-1}+h$ and $h=2/n$. Now given a function $f$ , I want to find $f(x_i)$ for $i=1:...
0
votes
1answer
291 views

creating a tridiagonal matrix in scilab/matlab

I want to create a tridiagonal matrix in scilab/matlab such that it uses for loops. I dont know how to create the matrix but here is what i have started ...
2
votes
0answers
180 views

Phase retrieval via SDP (semidefinite program) of 2D test image (Matrix completion)

In SDP based phase retrieval we have intensity measurement (abs(FFT2(x))^2) of the form A(xo) = |ak,x|^2 =b^2, phase retrieval is then find x that obeys A(xo)=b The quadratic measurements can be ...
1
vote
1answer
96 views

analytic/euler/runge kutta solutions comparison problem

i've been trying to solve 1st order differential equations with dsolve, euler andy runge kutta methods and compare them on graphics. for simplification, dy means dy/dx: first equation is y' = exp(-2*x^...
1
vote
1answer
200 views

How to find the zeros of an integral?

I am having trouble finding the roots of an integral. For example $F(c)=\int_a^b{(x^2-c^2)}dx$ for some finite interval $[a,b]$. The problem is that I am trying to do this using numerical analysis. ...
1
vote
1answer
66 views

Matlab help to construct matrices with specified rank and such that each eigenvalue is real

I am reading this paper, where at page $68$, section 3.3 (numerical examples for the Drazin inverse), the randomly generated matrix with specified rank and with the property that each eigenvalue is ...
0
votes
1answer
57 views

Linear Algebra Matlab matrix loop? [duplicate]

I'm new to both linear algebra and Matlab, so naturally I'm probably asking an obvious question. If someone could attempt to explain to me in layman's terms how to go about answering this question in ...
1
vote
0answers
96 views

Discretization of a convolution integral for constrained optimization problem

I'm working on a constrained optimization problem in which an unknown forcing function, $u(\eta)$, is in the integrand of a convolution integral. To find an optimal shape for $u(\eta)$, the integral ...
1
vote
1answer
67 views

Hand calculation of magnitude of transfer function doesn't equal what MATLAB says…

I have a simple transfer function, given by: $$\frac{140,000}{s(s+100)}$$ I'm attempting to calculate the magnitude at $\omega$ = 100 rad/s. So I plug in, I get $\frac{140,000}{20,000}$ = 7 Then I ...
0
votes
1answer
190 views

Random sampling using Metropolis vs. Accept-Reject

I'm working on a project comparing the accept-reject (von Neumann) and Metropolis methods of sampling. I'm generating a sample of size $N$ from a normal distribution $N(1,(\frac{1}{2})^2)$. What I ...
22
votes
3answers
2k views

Matlab wrong cube root

How can I get MATLAB to calculate $(-1)^{1/3}$ as $-1$? Why is it giving me $0.5000 + 0.8660i$ as solution? I have same problem with $({-1\over0.1690})^{1/3}$ which should be negative.
1
vote
1answer
83 views

Incorrect indefinite integral on MATLAB?

any ideas why matlab is giving me an incorrect answer here? 1 set of commands syms x L N2 N2 = 6*x/L^2 - 2/L^2 N2 = (6*x)/L^2 - 2/L^2 expand(int(N2*N2)) ans = (...
-1
votes
1answer
49 views

How to Estimate the mean and covariances for all classes from training set?

A training set of 2000 samples ( value :2000 * 2 ) named training_set. how can i estimate the mean and covariances for all classes from training set. already tried mean and cov function.but every time ...
-2
votes
1answer
2k views

How to split a dataset in test and training set?

How can I split a data set in training and test data set after creating a data set named first_data (contains 3000 samples) in MATLAB? I want to split $2000$ samples as training and $1000$ ...
1
vote
1answer
275 views

Not able to use fzero function in Matlab

I am new to Matlab. I am trying to solve a non-linear equation using this inbuilt Matlab function called fzero() but it's not giving me the results. The main file ...
0
votes
0answers
1k views

Coupled Differential equation of second order in matlab

I have a problem solving a system of differential equations of second order in matlab: $$ \left\{ \begin{array}{l l}\frac{d^2y}{dt^2}= \frac{-y}{(x^2+y^2)^{3/2}}\\ \frac{d^2x}{dt^2}= \frac{-x}{(x^2+...
1
vote
1answer
1k views

Determining the value of ECDF at a point using Matlab

I have a data $X=[x_1,\dots,x_n].$ In Matlab, I know by using [f,x]=ecdf(X) plot(x,f) we will have the empirical distribution function based on $X$. Now, if $x$...
0
votes
1answer
89 views

Understanding the transformation of values when plotting logscale in Matlab.

I'm playing with some transistor test data and having trouble understanding what is probably a very basic principle. Below are my two graphs, plotted linearly and then with a logarithmic scale on the ...
0
votes
1answer
130 views

MATLAB Feedback

I am trying to use the feedback function in matlab and for the most part I understand it. But I came across this syntax: [x1 x2] = feedback(sys1, sys2, 1, 1, -1); ...
0
votes
1answer
232 views

How to convert rational numbers to irrational numbers in disp in Matlab

How can I convert rational numbers to irrational numbers in $\operatorname{disp}$ in Matlab? I wrote a method in Matlab to estimate the value using the Newton-Raphson Method but when I use $\...
1
vote
1answer
111 views

Where is the fixed point? — Matlab is cluless too

Consider the differential equation $$\dot{k}(t)=f(k)-(r+t_1)k-f(1-k)+(r+t_2)(1-k)$$ where $k,t_1,t_1\in[0,1]$, $r\in\mathbb{R}$ and $f:[0,1]\to\mathbb{R}_+$. I'd like to solve for the fixed point $k_\...
1
vote
2answers
158 views

MATLAB Eigenvalues

So I am trying to get matlab to output the correct eigenvalue/eigenvector of a matrix. The matrix is: \begin{array}{ccc} 0 & 1 \\ -3 & -4 \end{array} The eigenvalues are: $\lambda_1 = -1, \...
0
votes
0answers
388 views

Matlab project - Jacobi method for tridiagonal matrices…

I have to do a project in Matlab to my University and I don't quite understand what I should do. I was given script that solves systems of equations with Jacobi's method with given tolerance and ...
0
votes
1answer
43 views

Large error after factoring h from fourth-order Runge–Kutta method

Consider $$\frac{dy}{dx} = 2x-y, \qquad y(0)=1$$ That has an exact solution $y(t) = 2t+3 e^{-t}-2$. But I want a numerical solution. So I decided to use forth-order Runge–Kutta method ...
0
votes
1answer
97 views

Matlab calculate output

I'm trying to write a matlab function that takes in a transfer function and the input so it can calculate the output. So far, based on this information under I have the following piece of matlab code:...