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

How to compute values of Legendre polynomials

The legendre polynomials are recursively defined as follows $L_{k+1}(x)=\frac{2k-1}{k}xL_k(x)-\frac{k-1}{k}L_{k-1}(x)$ I want to calculate the value of $L_k(x)$ for any given value $x$. I used the above recursion to come up with the following…
XPenguen
  • 2,301
0
votes
1 answer

Plotting impulse and step responses on Matlab

I'm trying to graph a simple response function: 1/(1-0.5s^-1) Now, I know that the function can also be written as: s/(s-0.5) So I tried plotting the step and impulse responses in Matlab: sys = tf([1 0],[1…
Jack
  • 3
  • 2
0
votes
1 answer

Undefined Variable in Matlab

I wrote the following Matlab function: function $s = Stirling(x,t)$ equation $$ \frac{(s^{(s+0.5)})}{(s-t)^{(s-t+0.5)}}=x.\times exp(t).\times t!$$ $s=$solve (eqn, $s$); end Now when I run the command $Stirling(18,3)$ for example, I expect to get a…
0
votes
1 answer

Matlab usage of the function fitnlm

I am using the function fitnlm : f= @(a,x)(a(1)*log(x+a(2))); mod= NonLinearModel.fit(A,B,f,[3,1]) for some data points (A,B)). The output is I am having a problem how to get separately the values of a(1) and a(2) to use them in an internal …
Nizar
  • 2,782
0
votes
1 answer

Need little help in making matlab code related with iteration methods

I have made following matlab code for computing the Moore-Penrose inverse of a given matrix A. A = randn(100) % given matrix beta = 1/norm(A,2)^2 x0 = beta.*A' % initial approximation, A' is the transpose of matrix A k =…
Srijan
  • 12,518
  • 10
  • 73
  • 115
0
votes
1 answer

Integral of symbolic expression on one of 2 variables

I have a function defined like this: syms t; syms y; x(t,y) = t*y; Now I want to know the integral of this symbolic expression, by fixing y as a constant, from 0 to inf. is there a way to do this using a symbolic expression, containing 2 variables?…
Cher
  • 163
0
votes
1 answer

Can we generate random singular matrices with desired condition number using matlab?

Recently, I studied A research paper where author has compared his proposed method with several other existing method on a randomly sigular matrices with fixed condition number. My question is can we generate a random matrices with desired…
Srijan
  • 12,518
  • 10
  • 73
  • 115
0
votes
1 answer

How to import a sequence of files into a cell in matlab?

I'm working on class assignment. I've to construct a hidden markov model for a give sequence of discrete data. The data is a 2-dimensional vector separated by comma in which each line represents x,y coordinates. I've been given 500 files each for 3…
0
votes
1 answer

Simulating Buffon's needle on Matlab

I am trying to simulate dropping Buffon's needle onto an A4 sheet of paper, but I am not sure how can I construct an A4 size area (21 x 29.7) and define 2 vertically line at 7cm and 14cm in Matlab. I also need to check if the needle(5cm) has…
phantom
  • 199
0
votes
1 answer

How to padleft with a variable number of digits?

I kknow I can pad a number up to 3 digits this way: prematrix = sprintf('%03d', prematrix); but what if I want a number of digits stored in a for example?
Cher
  • 163
0
votes
2 answers

how can i save a cell aray in matlab for ever?my project about finger vein identification

How can I save cell array in matlab when the program is over, that the programm running again use the same previous cell array?
marzie
  • 11
0
votes
0 answers

Question about outputs of a function in MATLAB

In MATLAB when we want to use a function with some outputs (more than one), and we use ~ instead of those that we do not want. For example like the following:\ [Output we need,~,~,~]=function name(input) Now the question is , when using ~ means that…
Rosa
  • 1,502
0
votes
1 answer

Drawing a monkey saddle surface in matlab?

I'd like to draw a monkey saddle surface using matlab. But how do I plot a function of several variables in matlab? I never did that before. I can define $x$ and $y$ as two vectors and then according to wikipedia the monkey saddle equation is…
0
votes
1 answer

MATLAB solve a single equation

I am trying to solve this equation: $e^x=x^e+e$ in MATLAB, but I continually get an error. I do not know where to go from here. Any help is appreciated This is what I have: a = x^exp(1) + exp(1) == exp(x); syms x b = solve(a,x); disp(b);
Nate
  • 1
0
votes
2 answers

do math operation on two arrays of different sizes

so I'm trying to find the minimum distance between each point in a large array with that of a smaller array. The following works for a single point. m = [-3, -1, 1, 3]; r = [.2, -1, .39, 3.6, -1.8.....] [minVal ind] = min((r(1) - m).^2)) What i'm…