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 lists in matlab

I'm working on a matlab project: We just started matlab, we haven't had any tutorials, just projects. We were giving a handout for it but it doesn't help. I'm really confused about this
Drew U
  • 199
1
vote
2 answers

How to have every 0 1 possible combination in a NXM matrix?

AS the title say. For example, imagine M = 2 and N = 2, I would like to have 0 0 0 0 SPACE 0 0 0 1 SPACE 0 0 1 0 SPACE 0 0 1 1 SPACE 0 1 0 0 SPACE 0 1 0 1 SPACE 0 1 1 1 SPACE etc... Every time I obtain one of the said matrix, I would need…
Cher
  • 163
1
vote
2 answers

How to solve this system in matlab?

$$\begin{align} x_1 &= 20000+0.5x_2+0.1x_3 \\ x_2 &= 40000+0.2x_1+0.6x_3 \\ x_3 &= 20000+0.1x_1+0.25x_2 \end{align} $$ I want to write the system as $Ax=b$, what will then $A$, $b$ and $x$ be? I suppose $x$ should be $[x_1, x_2, x_3]$ but…
1
vote
2 answers

How to generate a $30\times30$ matrix $A$ where the elements of the matrix are randomly taken from $[-0.2, 0.2]$.

I am beginner in matlab. I want to generate a a $30\times30$ matrix $A$ where the elements of the matrix are randomly taken from $[-0.2, 0.2]$. I am not able to make code for this? Could anybody help me with this? Question might be very…
Srijan
  • 12,518
  • 10
  • 73
  • 115
1
vote
2 answers

3D graphing in matlab

I'm having trouble graphing using Matlab, and was hoping someone could help. I just want to hand the program a function like $z=x^2-3xy+2$, or whatever, and have Matlab generate a 3D graph. From the tutorials I've seen online, it seems like this…
dan
  • 427
1
vote
1 answer

using MATLAB to solve a linear program

Hello I am very new to MATLAB and having difficulty solving a linear program problem using MATLAB, I tried solving it however I am not sure If i did it correctly Use MATLAB to solve the following linear program problem $f = 170 x_1 + 160 x_2 , f :…
Michael.K
  • 119
1
vote
0 answers

Interpreting the angle from the angle obtained by atan2 function

I have two signals ($x$ and $y$) whose absolute phases I'm calculating by using the atan2 function. Then subtracting both I'm getting the relative phase between two signals. Because the absolute phase is calculated by atan2, its range is…
rahdirs
  • 13
1
vote
0 answers

Matlab code for generating rank deficient random matrix of order $m\times n$

I am trying to make matlab code for generating rank deficient random matrix of order $m\times n$, $m > n$. Rank deficient matrix: Here $m\times n$, $m > n$ matrix $A$ would be rank deficient if $rank (A) = r < n$. I think this could be done by…
mathscrazy
  • 1,837
1
vote
1 answer

Gaussian Elimination Script

I'm trying to use the following script: > function [x,An,Ln,counter]=gausselim(A,b,details) % This function performs Gaussian elimination % on the square matrix A with right hand side b. % % INPUT: square (n,n) matrix A % (n,dimb) vector b %…
1
vote
4 answers

Got to learn matlab

I have this circuits and signals course where i have been asked to learn matlab all by myself and that its treated as a basic necessity now i wanted some help as to where should i start from as i hardly have around less than a month before my…
Bach
  • 537
1
vote
1 answer

How to enter large functions in pdetool of MATLAB

I am working with pdetool of MATLAB for solving certain parabolic pde. As you know there are prescribed format in pdetool for example in the parabolic case we have $$du^{'}+{\rm div}(c*{\rm grad}(u))+a*u=f$$ where the values of $d,c,a,f$ should be…
All
  • 303
1
vote
1 answer

Graphing $f(x,y) = x / (x^2 + y^2)$ in matlab

I have been having trouble plotting the following in MatLab: $$f(x,y) = \frac{x}{x^2 + y^2}$$ I seem to have no trouble plotting similar functions (using a meshgrid). In fact, if I just try plotting $z = x^2 + y^2$, I don't run into any issues. Why…
user184881
1
vote
1 answer

Plotting 2 parameters function in MATLAB

I want to plot 2 functions in MATLAB. First one is like this: X=[0.1 0.2 0.3]; Y=[5 4 1]; plot(X,Y); and the second one that I want to plot on the last function at the same figure is $$x^{2}y+3x+4y^{2}=1$$ I really confused about that!!
1
vote
1 answer

How to input equations in MATLAB and operate on them?

I'm using MATLAB R2013a. I want to input an equation in Matlab, e.g., $f(x) = x^2 - 2 x + 3$. I want it to be inputted by the user. I use the inline function for this: func = input('Enter a function: ','s'); f = inline(func); I have been able to do…
1
vote
1 answer

Solving a system of ODE (3 equations) using runge-kutta method order 4 - Matlab

$$x' = \lambda - \rho x - \beta xz \\ y' = \beta xz - \delta y \\ z' = py - cz$$ $x_0=43100, y_0 = 0, z_0 = 0.0033$ $\lambda = 388, \rho = 0.009, \beta =3.61e-8, \delta = 0.18, p = 50000, c = 23. $ my code is as follows: f = @(t,x)…
ChrisK
  • 13