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
0 answers

Too many output arguments error when using lsqcurvefit in matlab

I have a set of 7 ordinary differential equations and 1 algebraic which I use to calculate the concentrations of 8 species with time. I have also conducted experiments to measure the concentrations of such 8 species. The challenge I have now that…
0
votes
1 answer

Complex integral using matlab

Let $f(s)$ be a function. I would like to compute the following integral using Matlab $$ I=\int_{c-i\infty}^{c+i\infty}f(s)s^{-s}ds. $$ How can we use Matlab to evaluate this integral. Is the following notation convenient : syms s…
Monir
  • 168
  • 9
0
votes
1 answer

Matlab, anonymous functions, making a piecewise function, how?

If I want to make a piecewise function where lets say $f(x) = x^2 +1$ at $1 \leq t \leq 2$ and zero elsewhere. How can I make this possible using an anonymous function? I wanted to invent y = @(t) ((t.^2 + 1)*(t>=1)&&(t<=2)) But that obviously…
0
votes
1 answer

Implementing an awfull long function in MATLAB

I have a function $$ f(\tau, X_1, X_2, V_1, V_2) = \ e^{A(\tau) + z_1 X_1 + z_2 X_2 + B_1(\tau)V_1 + B_2(\tau)V_2+ B_m(\tau)V_m} $$ That I want to implement and do some numerics on in MATLAB. The thing is that its awfully long when inserting…
Olba12
  • 2,579
0
votes
1 answer

Difficulty understanding the notation/arguments in the following plot function in MATLAB

I am currently reading through examples on how to display wav files in Matlab and I came across this example, but I am not sure what the arguments reprent inside the plot function: Create this figure in Matlab: $x = $wavread(‘horn.wav’); plot$(x(:,…
Belphegor
  • 1,268
  • 6
  • 27
  • 51
0
votes
0 answers

To find outlier based on N points on sine curve

Suppose N points ((x1,y1),(x2,y2),...(xN,yN)) are given from a curve y=sin(ax+b) where a,b values are unknown. Before giving these N points to you, y coordinate of one point is randomly tampered so that it does not lie on the curve. Write a program…
0
votes
1 answer

Summation and for looping in matlab

I have a basic code that I'm struggling to make it work on matlab. Any help would be appreciated. M = [1 2 3 4 5]; for t=1:5; if t<2; fx=10*exp(-0.1) else fx=sum(5.*exp(-0.1*(t)))+10*exp(-0.1*M(t)) end end so I am essentially…
0
votes
1 answer

Program to find Saddle points matlab

I am trying to write a program that will take in a matrix (lattice) that defines a surface and find all the saddle points. I was trying to use finite differences and the second partial derivative test to find the saddle points. I have tried all the…
MathIsHard
  • 2,733
  • 16
  • 47
0
votes
0 answers

Replicate a Null space in Matlab

I want to replicate this Null space in Matlab https://www.youtube.com/watch?v=qvyboGryeA8 $$ \begin{pmatrix} 1 & 1 & 1 & 1 \\ 1 & 2 & 3 & 4 \\ 4 & 3 & 2 & 1 \\ \end{pmatrix} $$ With this vector as result $$ …
Jorge
  • 13
0
votes
1 answer

Difficulty in sarrus method matlab

What is the matlab code for determining 3x3 matrix using sarrus method?
Virat
  • 9
0
votes
0 answers

square matrix in Matlab

How I can create a square matrix for a fixed dimension such that each element in this matrix is a function e.g., \begin{equation} A=\left(\begin{array}{ccc} x & \sin x & x^2\\ 1-x & e^x & 2x & \\ \cos x & x-2 &…
S.N.A
  • 199
0
votes
1 answer

How can calculate f?

I have a loop, in each iteration I want to compute $f(X)$ such that $X$ is a vector. When I wrote f=@(x,y) (x+2)^2+(y-x)^3 and X=[1,5], I have an error in f(X). How can write function $f(X)$ such that $X$ can be a vector? And suppose we can't use…
0
votes
3 answers

How would i go about plotting this in matlab

So I have this matrix A = [1.9, 0.025; 0.1, 1.225]; And I want to multiply it with the vector v = [1;0]; I want to plot the sum of it up to 25 iteration, so I have a for loop and I use the sum function like this: iter = 25; v = [1;0]; for k =…
Corvo
  • 61
0
votes
4 answers

Help me matlab,find $f(x)$ from $f(g(x))$....thanks a lot!

How to find $f(x)$ from $f(g(x))$, $g(x)$, ex: $g(x)=1-x^2$ $f(g(x))=(x^4+x^2)/(1+x^2)$ $f(1/2)=$ use matlab code....I don't know..help me thanks a lot!
0
votes
0 answers

MATLAB Script to Run Formula with Multiple Variables

I'm trying to plot $$p(n)=1-\sum_{i=0}^{\lfloor n/2 \rfloor}\frac{365!n!}{i!(365-n+i)!2^{i}(n-2i)!365^{n}}$$ over various positive integer values of $n$ in MATLAB, but it obviously has very large numbers in it deriving from the factorials leading…
Agnes
  • 195