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

plotting an fft function

need to plot the folowing: $$X(j\omega)=\cal F\{{2\over\pi\lambda}\}*\cal F\{sinc(2w_m\lambda)\}-\cal F\{{4\over\pi\lambda}\}*\cal F\{sinc(w_m\lambda)\}$$ as a plot of $|X(j\omega)|$ for $|\omega|<10\pi$ the code I've wrote is: %% define t =…
1
vote
1 answer

Plotting multiple curves using ODE45

I am a beginner to using MATLAB, and I need a lot of help to understand what to do here. I would like to plot multiple curves using different initial conditions to my system of ODEs. Here is my code: f = @(t,x)…
Marc
  • 11
1
vote
1 answer

Is Matlab free from cancellation of digits in solving elementary equations?

Few days ago,I had a problem solving elementary equations in flash action script 3. I asked here and got an anwer ,I thank him very much. How to safely solve a pair of elementary equations in a floating point computing system? I temporary fixed…
1
vote
1 answer

A signal with multiple frequencies...

I'm doing an assignment on Fourier series in MATLAB. The first part states: Generate a signal with frequencies $50$Hz, $150$Hz and $300$Hz. I can easily generate a signal with one frequency, but how do I generate one signal with all frequencies…
1
vote
1 answer

How to turn off scientifc notation when using char command in Matlab?

I want to convert a polynomial expression into an array of characters in MATLAB. We are using the command char. On my computer, char will change the format of the coefficients of a polynomial to scientific notation. For example, char(x^2 +…
Pew
  • 643
0
votes
1 answer

Matlab: Accessing parts of anonymous functions

If I define an 2 by 1 vector anonymous function in MATLAB: F=@(x,p)[a*x(1)*(1-x(1))-x(1)*x(2)-p*(1-exp(-q*x(1)));... -x(2)+b*x(1)*x(2)*exp(-x(2)/c)]; is there a way for me access just the first and second components of the function? More generally,…
Fryderyk
  • 125
0
votes
1 answer

Matlab integral with parameter

I'm a beginner with Matlab, and I'm trying to solve the following problem. I'd like to define a function $$F(x) = \int_0^{+\infty} \frac{\sin t}{1 + xt^4} \, dt$$ and plot it on the interval $[1,3]$. I wrote the following code: x = 1:0.01:3; y =…
0
votes
1 answer

How to isolate colour Green from the Picture.

The picture is: How do I isolate the green chips? The result must be in black and white. It doesn't have to be perfect. To isolate the blue ones I used: I=imread('Picture.png'); A=I(:,:,3); B=(A>230) figure imshow (B) How do I…
George
  • 13
0
votes
2 answers

Matlab: variable-dependent dot product in anonymous function

I have an anonymous function like this one: f = @(t) 5.*cos(t) + 10.*sin(t); f([1,2]) ans = 11.1162 7.0122 Is it possible to define f using a dot product operation or similar, something along the lines of this? f = @(t) dot([5,10], [cos(t),…
0
votes
1 answer

Creating a tridiagonal matrix in Matlab with smaller matrices

This is the problem. Given a matrix B = \begin{bmatrix} 6&-1&0\\-1&6&-1\\0&-1&6 \end{bmatrix}. and I = 3 x 3 identity matrix, how can I construct D = \begin{bmatrix} B&-I&0\\-I&B&-I\\0&-I&B \end{bmatrix}? I know that B can be easily created using…
0
votes
2 answers

Using nested if statements in matlab

function methods = prj2() a = input('enter the function', 's'); f = inline(a); itr = 0; lim = 0.00001; c = input('enter the method number, 1 for secant, 2 for newton, 3 for QII'); if (c == 1) x(1) = input('enter the first guess'); …
hs2345
  • 123
0
votes
2 answers

Help with secant method using MATLAB

function Problem1 = SecantMethod() a=input('enter function:','s'); f=inline(a) x(1)=input('enter first guess: '); x(2)=input('enter second guess: '); n=input('enter tolerance: '); iteration=0; i=2; while (abs(x(i))>0.00001) …
hs2345
  • 123
0
votes
1 answer

Computing Polygonal Surface in Matlab

I am given a bunch of points in 3D-space and want to analyze their convex hull. What I am interested in is what kinds of polygons appear on the surface of the convex hull (probably mostly triangles, but maybe there are also quadrilaterals, etc). To…
Lucas Mann
  • 1,813
0
votes
2 answers

Overlaying scatter points over world map in MATLAB

I am facing difficulty overlaying lightning location data over a region of the world map. I have lightning location data where the first column contains longitude and the second column latitude. I would like to plot these lightning locations as…
0
votes
3 answers

Using MATLAB to find the max elements and their positions

MATLAB documentation says "[C,I] = max(...) finds the indices of the maximum values of A, and returns them in output vector I." But that does not seem to work. See below. X = [2 8 4; 7 3 9]; [a,b] = max(X) a = 7 8 9 b = 2 1 …