i and j are very popular variable names (see e.g., this question and this one). For example, in loops: for i=1:10, % do something... end As indices into matrix: mat( i, j ) = 4; Why shoul...
I am writing a program where I need to delete duplicate points stored in a matrix. The problem is that when it comes to check whether those points are in the matrix, MATLAB can't recognize them in the...
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(3,3); to get value == 13. I'd like to be able to do something like one of these: value...
The following error occurs quite frequently: Subscript indices must either be real positive integers or logicals I have found many questions about this but not one with a really generic answer. ...
This question pops up quite often in one form or another (see for example here or here). So I thought I'd present it in a general form, and provide an answer which might serve for future reference. ...
I am making some benchmarks with CUDA, C++, C#, and Java, and using MATLAB for verification and matrix generation. But when I multiply with MATLAB, 2048x2048 and even bigger matrices are almost insta...
Consider the following simple speed test for arrayfun: T = 4000; N = 500; x = randn(T, N); Func1 = @(a) (3*a^2 + 2*a - 1); tic Soln1 = ones(T, N); for t = 1:T for n = 1:N Soln1(t, n) = F...
We are used to different forms of indexing in Matlab: standard (using integers along each dimension), logical (using logical values), linear (using a single index to traverse an array with more than...
I have 200 time points. For each time point, there is an image, the size of which is 40*40 double, corresponds to this time point. For example, image 1 corresponds to time point 1; image k corresponds...
I'm experimenting with MATLAB OOP, as a start I mimicked my C++'s Logger classes and I'm putting all my string helper functions in a String class, thinking it would be great to be able to do things li...