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

Plot the partial sums of a series - Matlab.

I want to plot the partial sums of the reciprocals of the squares between 1 and 10. So far, I've got the following code. It's something along these lines, but I can't quite manage it. I need to sum the terms so far for each point between 1 and 10,…
M4thGy
  • 11
1
vote
1 answer

Find best offset between 2 sets of numbers

Imagine I have the following vectors: A = [ 1 5 9 12 16] B = [ 1 4 ] Now I am looking for an offset, that makes B an subset of A. In this example it would be 8, because B+8 gives numbers that are included in A: A = [ 1 5 9 12 16] //…
me.at.coding
  • 141
  • 4
1
vote
3 answers

How to find the first root of a cubic equation in matlab

Question: Given a cubic equation where the coefficients are real but can take any extreme conditions (e.g very large or very small number), write a program in Matlab that finds all the roots of this equation. You can't use the built-in functions…
1
vote
1 answer

Linear interpolation in a table

I have the following table: How do I use linear interpolation to fill in the data under 400?
mgblair
  • 11
1
vote
2 answers

Using MATLAB to analyse freefall.

A ball is thrown up into the air at an initial speed v of $30$ $m /s $. Assume the acceleration due to friction against the air is directed opposite to the direction of the velocity, and proportional to the speed of the ball, such that the total…
1
vote
2 answers

Randomly choose any number of elements within a given sample randomly

If I want to arbitraraly choose any number $(1\sim9)$ of arbitrarily elements within $(1\sim9)$: Ex: 1. $n = 3$ (randomly) $\rightarrow$ choose $"1,4,9"$ (randomly & no repeat) 2. $n = 2$ (randomly) $\rightarrow$ choose $"9,10"$ (randomly & no…
sleeve chen
  • 8,281
1
vote
1 answer

Using Fonts from the Fourier LaTeX Package in MATLAB's Plots

I'm using the fourier package to make my $\LaTeX$ documents look pretty, but they would be even prettier if I could mimic the same font in legends, axis labels etc. in my Matlab plots. I know there are ways to find-and-replace texts in eps graphics…
1
vote
0 answers

problem implementing leave-one-out cross validation for optimal bandwidth in Matlab

I'm trying to solve an exercise in which I need to calculate the local constant kernel estimator and provide the bandwidth using leave-one-out cross validation. The idea is that I need to sort of implement this in Matlab and not use some built in…
Corel
  • 111
1
vote
0 answers

How to calculate the lower triangular matrix as in QR factorization in matlab?

Tried >[Q,R] = qr(a) R is upper triangular part of >qr(a) as qr(a)'s lower triangular part has value but how to calculate the >qr(a). Would like to do this in F# but Sho library's Q, R are different from matlab, hope there is a way to fix it. Just…
M-Askman
  • 281
1
vote
0 answers

Error in script for estimating $\pi$

I am new to matlab, and am trying to write a script for this equation for n=100: And am using this: n = 100; % set number of terms sum = 1; % starting point of the sum sign = 1; % an integer +/- 1 for k = 1 : n % forloop - loops k from 1 to n …
elbarto
  • 3,356
1
vote
3 answers

3D plot problem

I have a matrix $(A_{10*10})$ in which each elements of matrix states the value of the function $y=f(x,y)$. Since, $y$ shows the enclosed area between two squares, so I don't have the value of these elements in this area. Now my question is that how…
roza
  • 11
  • 3
1
vote
0 answers

how to conceptually visualize data structures in Matlab

I tend to think of data structures of type Structure.Field.Subfield as analogous to file directories. I.e that Structure is a folder and Field is a folder inside the folder.. etc. Is this a good way to think about it?
user32882
  • 702
1
vote
1 answer

Matlab help to construct matrices with specified rank and such that each eigenvalue is real

I am reading this paper, where at page $68$, section 3.3 (numerical examples for the Drazin inverse), the randomly generated matrix with specified rank and with the property that each eigenvalue is real and has single multiplicity is constructed. It…
Srijan
  • 12,518
  • 10
  • 73
  • 115
1
vote
1 answer

Hand calculation of magnitude of transfer function doesn't equal what MATLAB says...

I have a simple transfer function, given by: $$\frac{140,000}{s(s+100)}$$ I'm attempting to calculate the magnitude at $\omega$ = 100 rad/s. So I plug in, I get $\frac{140,000}{20,000}$ = 7 Then I do $20log_{10}(7)$ = 16.9 Yet when I go through…
krb686
  • 685
1
vote
1 answer

MuPAD equation solving

I have x(t) defined as: x(t) = Symbol::subScript(x,0) + Rb*`φ`(t) I want to write the derivative of phi(t) in terms of x(t). When I try diff(`φ`(t),t) it doesn't substitute from the x(t) equation.
romanbird
  • 177