Tag: matlab

66 votes
3 answers
625 views
Why does numpy std() give a different result to matlab std()?

I try to convert matlab code to numpy and figured out that numpy has a different result with the std function.

avatar
Patsy
0 1 0 9
asked 07 September, 2021
67 votes
6 answers
1.3K views
Hash tables in MATLAB

Does MATLAB have any support for hash tables? Some background I am working on a problem in Matlab that requi

avatar
Patsy
0 1 0 9
asked 07 September, 2021
63 votes
2 answers
1.6K views
Octave / Matlab: Extend a vector making it repeat itself?

Is there a way to extend a vector by making it repeat itself? >v = [1 2]; >v10 = v x 5; %x represents s

avatar
Georgie
0 1 0 9
asked 07 September, 2021
58 votes
7 answers
1.7K views
Map function in MATLAB?

I'm a little surprised that MATLAB doesn't have a Map function, so I hacked one together myself sinc

avatar
Wilfredo
0 1 0 9
asked 07 September, 2021
66 votes
7 answers
2.3K views
What's the difference between & and && in MATLAB?

What is the difference between the & and && logical operators in MATLAB?

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
56 votes
8 answers
2.2K views
How to get all files under a specific directory in MATLAB?

I need to get all those files under D:\dic and loop over them to further process individually. Does MATLAB su

avatar
Scot
0 1 0 9
asked 07 September, 2021
63 votes
2 answers
2K views
arrayfun can be significantly slower than an explicit loop in matlab. Why?

Consider the following simple speed test for arrayfun: T = 4000; N = 500; x = randn(T, N); Func1 = @(a) (3*a^

avatar
Yolando
0 1 0 9
asked 07 September, 2021
54 votes
7 answers
730 views
What is the equivalent of MATLAB's repmat in NumPy

I would like to execute the equivalent of the following MATLAB code using NumPy: repmat([1; 1], [1 1 1]). How

avatar
Hallie
0 1 0 9
asked 07 September, 2021
52 votes
8 answers
1.3K views
How to search for a string in cell array in MATLAB?

Let's say I have the cell array strs = {'HA' 'KU' 'LA' 'MA' &ap

avatar
Winford
0 1 0 9
asked 07 September, 2021
55 votes
11 answers
842 views
How can I apply a function to every row/column of a matrix in MATLAB?

You can apply a function to every item in a vector by saying, for example, v + 1, or you can use the function

avatar
Adolfo
0 1 0 9
asked 07 September, 2021
59 votes
5 answers
1.4K views
Automatically plot different colored lines

I'm trying to plot several kernel density estimations on the same graph, and I want them to all be differ

avatar
Dusty
0 1 0 9
asked 07 September, 2021
57 votes
10 answers
1.5K views
Matlab: Running an m-file from command-line

Suppose that; I have an m-file at location:C:\M1\M2\M3\mfile.m And exe file of the matlab is at this locatio

avatar
Lashawna
0 1 0 9
asked 07 September, 2021
61 votes
8 answers
1.2K views
How to elegantly ignore some return values of a MATLAB function

Is it possible to get the 'nth' return value from a function without having to create dummy variable

avatar
Carmelina
0 1 0 9
asked 07 September, 2021
59 votes
12 answers
2K views
What is the Python equivalent of Matlab's tic and toc functions?

What is the Python equivalent of Matlab's tic and toc functions?

avatar
Dorinda
0 1 0 9
asked 07 September, 2021
57 votes
16 answers
1.4K views
How do I set default values for functions parameters in MATLAB?

Is it possible to have default arguments in MATLAB? For instance, here: function wave(a, b, n, k, T, f, flag,

avatar
Elicia
0 1 0 9
asked 07 September, 2021
57 votes
5 answers
602 views
In MATLAB, when is it optimal to use bsxfun?

I've noticed that a lot of good answers to MATLAB questions on Stack Overflow frequently use the functio

avatar
Suzan
0 1 0 9
asked 07 September, 2021
56 votes
9 answers
1.9K views
Using i and j as variables in MATLAB

i and j are very popular variable names (see e.g., this question and this one). For example, in loops: for i=1

avatar
Rudolf
0 1 0 9
asked 07 September, 2021
59 votes
4 answers
2.6K views
Is MATLAB OOP slow or am I doing something wrong?

I'm experimenting with MATLAB OOP, as a start I mimicked my C++'s Logger classes and I'm puttin

avatar
Benton
0 1 0 9
asked 07 September, 2021
59 votes
9 answers
993 views
Is there a foreach in MATLAB? If so, how does it behave if the underlying data changes?

Is there a foreach structure in MATLAB? If so, what happens if the underlying data changes (i.e. if objects a

avatar
Dario
0 1 0 9
asked 07 September, 2021
56 votes
6 answers
3.1K views
How to get the type of a variable in MATLAB

Does MATLAB have a function/operator that indicates the type of a variable (similar to the typeof operator in

avatar
Boyd
0 1 0 9
asked 07 September, 2021