Tag: r

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
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
846 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
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
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
606 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
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
51 votes
12 answers
1.9K views
Why is MATLAB so fast in matrix multiplication?

I am making some benchmarks with CUDA, C++, C#, Java, and using MATLAB for verification and matrix generation.

avatar
Wei
0 1 0 9
asked 07 September, 2021
60 votes
9 answers
830 views
Is it possible to define more than one function per file in MATLAB, and access them from outside that file?

When I was studying for my undergraduate degree in EE, MATLAB required each function to be defined in its own

avatar
Majorie
0 1 0 9
asked 07 September, 2021
55 votes
10 answers
758 views
Representing and solving a maze given an image

What is the best way to represent and solve a maze given an image? Given an JPEG image (as seen above), wha

avatar
Serina
0 1 0 9
asked 07 September, 2021
68 votes
9 answers
459 views
How can I index a MATLAB array returned by a function without first assigning it to a local variable?

For example, if I want to read the middle value from magic(5), I can do so like this: M = magic(5); value = M

avatar
Rudy
0 1 0 9
asked 07 September, 2021
52 votes
9 answers
746 views
Openstreetmap: embedding map in webpage (like Google Maps)

Is there a way to embed/mashup the OpenStreetMap in your page (like the way Google Maps API works)? I need to

avatar
Winford
0 1 0 9
asked 07 September, 2021
61 votes
3 answers
1.3K views
Reading header data in Ruby on Rails

I am making an API where in the access token for Facebook login will be sent in through header data. How do I

avatar
Joseph
0 1 0 9
asked 07 September, 2021
61 votes
2 answers
2.6K views
API Keys vs HTTP Authentication vs OAuth in a RESTful API

I'm working on building a RESTful API for one of the applications I maintain. We're currently lookin

avatar
Hilario
0 1 0 9
asked 07 September, 2021
45 votes
7 answers
2.8K views
Allow Access-Control-Allow-Origin header using HTML5 fetch API

I am using HTML5 fetch API. var request = new Request('https://davidwalsh.name/demo/arsenal.json');

avatar
Freida
0 1 0 9
asked 07 September, 2021