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.

MATLAB (Matrix Laboratory) 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 biology. It is the foundation for a number of other tools, including Simulink and various toolboxes that extend its core capabilities.

In addition, MATLAB is a proprietary product of MathWorks. This means that, unlike other GNU GPL open source languages, both programmers and users must own a valid software license for running MATLAB code. There are several open source alternatives to MATLAB, in particular GNU Octave, which offers bidirectional syntactic compatibility with MATLAB, Scilab, SciPy, and Julia.

You could think about posting your question on Stack Overflow. They've got plenty of questions/answers already there.

Some informative links that show up quite often in answers:

User Amro has created a user-script for Matlab Syntax Highlighting for Stack Overflow. Use this link to install it.

3165 questions
1
vote
0 answers

Trying to implement Liebmanns method to solve a Laplace equation numerically

I'm currently stuck trying to solve Laplaces equation (2D problem) using numerically solution. I have several cases I'm supposed to solve for (assignment), and I think I've solved one of them. clc clear all L1=1; L2=1; nx=50; …
1
vote
0 answers

How to solve an algebraic Riccati equation when the Hamiltonian spectrum is too close to the imaginary axis.

I have to solve an algebraic Riccati equation but the care command of MATLAB is responding as "Unable to solve the specified Riccati equation because the Hamiltonian spectrum is too close to the imaginary axis." The equation is $$FX+XF'-XCC'X+Q=0$$…
Dee Kay
  • 11
1
vote
0 answers

Updating subplots based on data cursor value

I have plot with subplots. If I in one subplot use my data cursor to select some value, how can I automatically update another subplot with the $x$-value from the data cursor?
kasperhj
  • 197
1
vote
2 answers

'advanced' indexing question in matlab

I have an indexing problem in Matlab. Let's say that I have a array $A$ with $m$-dimensions with $m$ depending on the problem. So $A \in \mathbb{R}^{n_1 \times ... \times n_m}$ Suppose I have vector with indices $x = [i_2, ..., i_m]$ and I want to…
Koen
  • 682
1
vote
1 answer

Piecewise parameter in matlab

I'm trying to define this paramater in matlab for my system of differential equations code but i don't know how to work this out: What i tried: syms f f1 j = input('Enter value of j: '); T1 = 4.5; T2 = 0.83; if ((t >= T1+j && t <= T2+j)) f =…
1
vote
2 answers

Matlab, operator A\B

What is the result of the operation A\B, where A(1, m) and B (1, m)? In the manual it is written: A\B returns a least-squares solution to the system of equations A*x= B. So it means x = inv (A'*A)*A'*B? However, the matrix A'*A is singular... Let…
justik
  • 53
1
vote
0 answers

Accurate Algorithms for Calculating Inverses of Nearly Singular Matrices in MATLAB

I am currently working on a program that aims to take some steady-state probability distribution (specified by particular free parameters of my choosing) and propagates it to some other steady-state (also specified by the same set of modified…
1
vote
0 answers

Computing $\int_0^1\int_0^{1-x}f(x,y)\:{\rm d}y\:{\rm d}x$ using MATLAB

I want to compute $$\int_0^1\int_0^{1-x}f(x,y)\:{\rm d}y\:{\rm d}x$$ numerically using MATLAB R2012b. I wasn't able to figure out how I need to deal with the dependency on the first variable in the inner integral. So, how do I need to do this?
0xbadf00d
  • 13,422
1
vote
0 answers

Forming a first degree function from a collection of equations and constants

So I have a container with $V=Ah$ of liquid. $h_0$ is the starting height of the liquid and the amount of liquid the containers changes at $q=kh$, where $q$ is the rate of liquid draining per time unit, $k$ is a constant and $h$ is the height of the…
Grak
  • 209
  • 3
  • 10
1
vote
3 answers

Iterative solver for matrix division

I have two huge matrices $A$ and $B$. I am trying to find some iterative solvers like bcg or lsqr in Matlab. I mean if my matrix $A$ is sparse and $n\times n$ and $B$ is a column vector of size $n\times 1$, I can use lsqr and bcg to solve the…
user34790
  • 4,192
1
vote
1 answer

How to draw Reflection coefficient in MATLAB

I am trying to plot Reflection coefficient by using the formula indicated on the attached image and use the Matlab code below: Note: I use MATLAB R2015a E1=1; E2=2.32*E1; for tetai=1:90 …
Jack
  • 1
1
vote
1 answer

How to define this recursive formula in MatLAB

I have a matrix-valued function defined as R which depends on n and I want to define the following algorithm in MatLAB: $A_{0}=I$ , $B_{0}=0$ , $A_{1}=I$ ,$B_{1}=I$ for $j=1:2m$ $A_{j}= R_{j}A_{j-1}+A_{j-2}$;$B_{j}=…
Mary
  • 65
1
vote
1 answer

Need help to compute running time

I have made following matlab code for computing cpu time of matlab inbuilt function pinv(A) to compute the Pseudo inverse of a given matrix. I had runed the matlab code 1000 times & calculated the mean of the results. Matlab code A = rand(10) %…
Srijan
  • 12,518
  • 10
  • 73
  • 115
1
vote
4 answers

Generating a random singular matrices using matlab

Could anybody tell me that How one can generate a random singular matrices using matlab? I know that using rand(n) we can generate a random matrix of order n. But I found that these random matrices are non singular while I am interested in…
Srijan
  • 12,518
  • 10
  • 73
  • 115
1
vote
0 answers

Structure Array in Matlab

I have created a structure array in matlab as follows: clc; clear all; close all; field1 = 'relation'; value1 = {'Brother','Sister','Grandfather'}; field2 = 'name'; value2 = {'Samuel', 'Giorgia','Alex'}; field3 = 'state'; value3 = {'LA', 'NY',…