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
0
votes
1 answer

Building a function to display of the sum of matrices at different powers in Matlab

I'm trying to write a for loop for the sum A+A^2+A^3+..+A^n. Here is my code: function [ x ] = Untitled2( A , n ) for k=1:n, x =sum(A^k) end The problem I'm having with this is this function is listing the matrix A to each power without adding…
Heath Huffman
  • 589
  • 3
  • 10
  • 18
0
votes
1 answer

Script for the sum of the $j$-th powers of the first $n$ numbers in MATLAB

I'm trying to write a script for the sum of the $j$-th powers of the first $n$ numbers in MATLAB, so: $s(n,j) = 1+2^j+3^j+\cdots +n^j$ The function should have two inputs so I have started with: % Sum of the j-th powers of the first n…
Edward
  • 1
0
votes
1 answer

Computing in Matlab, for a $n\times2$ matrix, for each row$\theta_{0}*\text{first element in row}+\theta_{1}*\text{second element in row}$

I have a matrix $A$ s.t each row is of length $2$ and with the first element $=1$ for example $$ A=\begin{pmatrix}1 & 2\\ 1 & 5\\ 1 & 4 \end{pmatrix} $$ I have a function $h(x)=\theta_{0}+\theta_{1}x$ . I defined…
Belgi
  • 23,150
0
votes
2 answers

Why does "imread" generate 3 images?

The MATLAB help for imread says: A = imread(filename, fmt) The return value A is an array containing the image data. If the file contains a grayscale image, A is an M-by-N array. If the file contains a truecolor image, A is an M-by-N-by-3…
0
votes
1 answer

Deletion repeated rows of a matrix

I have a matrix that some rows of this matrix are repeated two times. I need to delete repeated rows to get a fullrank matrix, that I can do this with a loop. BUT is there anyone who know any function in matlab that do this ? Please hint me. Thanks.
Rosa
  • 1,502
0
votes
1 answer

how can I sort a matrix

I have coordinates of some points$(x,y)$, that I want to sort them,at the first by $y$ coordinates and second sort $x$ coordinates between those points that have equal $y$ coordinate. Is there anyone know any function in matlab about it? I examined…
Rosa
  • 1,502
0
votes
1 answer

awgn command in Matlab

I am unable to understand the command awgn in matlab.I considered the signal vector x=[1 2 3 4 5 6 7 8 9 10].The power of x is pow_x=norm(x,2)^2/length(x)=38.5000 and it's value in dB is pow_xdb=10*log10(pow_x)=15.8546 dB Now I want AWGN noise…
0
votes
1 answer

Snakes and Ladders - Matlab help!

I'm trying to write a simulation for snakes and ladders in Matlab but I'm stuck. How would I write something to check if the player is on a square that has a snake or ladder? I read somewhere that in Python you can just use something like "if…
0
votes
0 answers

Circle_cap coding in matlab

I would like to write a code to plot a circle cap like the shape below. In fact, $r,\; \theta$ and $a$ are given and I want to plot it using them. Note: It is not difficult to see that $a=r\sin \theta$. Also, you can consider the center of the…
6-0
  • 654
0
votes
0 answers

(MatLab) patternCustom 3D radiation plot not showing up

I am working on an antenna array working within wifi spectrum (2.4 GHz to 2.4835 GHz) for a university project, and as a part of that I have gotten it tested in a MVG SG24 with a frequency sweep from 2.4 GHz to 2.5 GHz. I have extracted the azimuth,…
JPed
  • 1
0
votes
0 answers

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, elements of pipe1 and pipe 3 will not experience any…
0
votes
1 answer

Help with Matlab commands?

The body's surface area is often using for determining doses of drugs. It's not easy to measure a person's surface area, so there have been various formulae proposed to estimate the surface area using a person's height and weight. Three formulae for…
0
votes
1 answer

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',inf) would solve the problem. However, this…
Cashman
  • 43
0
votes
1 answer

Matlab - How to make function handle depending on data?

So when you do something like @$(x) x^2+2$ you get the function handle of $f(x) = x^2+2$ in Matlab, and this can be used for calling the function on some solvers, but when you do function $[y] =$ xsquareplustwo(x) $y = x^2 + 2$; end you get the…
karlabos
  • 1,257
0
votes
2 answers

Meshgrid with a hole in MatLab

I am trying to create a meshgrid with a hole in MatLab using meshgrid command. Rectangular plate grid is very easy but excluding points inside the hole boundary, I have difficulty! "I want to exclude the little black disks (dont use the word…
ltxEnthu
  • 29
  • 4