Answered
How to fill in this matrix?
There are many roads to Rome. Here is another generic and fast solution: % example data time = zeros(3,26) % in your c...

12 years ago | 0

Answered
Matlab. Find the indices of a cell array of strings with characters all contained in a given string (without repetition)
Take a look at my function MATCHROW: str = 'actaz'; dic = {'aaccttzz', 'ac', 'zt', 'ctu', 'bdu', 'zac', 'zaz', 'aaz'}; ...

12 years ago | 1

Answered
Question about how to make something that points to a matrix
Try this x = [11 13 15 21] x(2) x([1 3]) x([4 2]) y = [3 2 4] x(y) % voila! x(20) % oops!

12 years ago | 0

Answered
fundamental principle of multiplication
p = [ 1 -1 j -j ] ; [a,b,c,d] = ndgrid(p) ; M = [a(:) b(:) c(:) d(:)]

12 years ago | 2

| accepted

Answered
Flipping Values (1 Line)
Like other, I totally fail to see why you need a for loop ... Anyways, this will work for k=1, [b,a] = deal(a,b) end...

12 years ago | 0

| accepted

Answered
Flipping Values (1 Line)
Hint: A(1) = 1 A(2) = 2 A([2 1])

12 years ago | 1

Answered
Testing to see if an if or elseif value is equal to a range of values?
To compare an element with a range or with a set, these three examples might be useful to see: if x >= 1 && x <6 disp...

12 years ago | 0

Answered
Can MATLAB create a column of words based on integer values in another column?
Take a look at *sprintf* and *arrayfun* : IDvalues = [1 3 100 12] IDnames = arrayfun(@(x) sprintf('Sub_ID%d',x), IDvalue...

12 years ago | 1

Answered
How do i cut a string after an amount of values or a delimiter
Here is a straighforward approach: % data: str = '1 2 3 4 5 6; 7 8 9 10 11 12; 13 14 15 16 17 18' % engine: ss = s...

12 years ago | 0

| accepted

Answered
How to loop the constant in a function?
What do you exactly mean by " _solve the function_ "? Do you mean that you have a set of points (X,Y), and you want to fit the...

12 years ago | 0

Answered
Breaking up a column vector
First of all, you do not want to have a variable named "load" as it clashes with the important function load Second, things bec...

12 years ago | 0

Answered
how to increase matrix size
Take a look at INSERTROWS: insertrows(A,NaN,1:size(A,1)) <http://www.mathworks.com/matlabcentral/fileexchange/9984>

12 years ago | 0

Answered
randsrc problem in my mtlab 2012b
Buy and install it?

12 years ago | 1

Answered
IS THERE ANY INBUILT TO CALCUALTE MEAN AND VARIANCE IN MATLAB
If a block means a N-by-M matrix called, e.g., BLOCK, you can get the mean of all N*M elements using mean(BLOCK(:))

12 years ago | 0

Answered
how to make zero padding?
Pad a matrix M with N zeros to all sides using indexing (neither trivial nor boring): M = ceil(10*rand(3,4)) N = 2 ...

12 years ago | 1

Answered
How to make two rows of a matrix correspond to a vector
For linear indexing it does not matter how a vector is stored internally. It matters for display purposes (and computations!). ...

12 years ago | 0

Answered
Finding common strings elements in array?
Get the final part of the strings, and compare them: C = {'5/22/2000', '5/22/2001', '15/23/2000'} % example from jan tf ...

12 years ago | 0

Answered
help me write the code
No ;-)

12 years ago | 1

Answered
Polyfit() does not seem to work well for some straight lines. Is there a good alternative?
Tip: always plot your data to see if a model would fit. In your case a linear model is simply a very bad choice, even more so wh...

12 years ago | 0

Answered
Excluding rows of data with NaN and writing to a new matrix, using indexing
A = [ 1 2 3 ; 4 5 NaN ; 6 7 8 ; NaN NaN 9 ; 10 NaN 11 ; 12 13 14] ; % a matrix with NaNs in some rows tf1 = isna...

12 years ago | 1

| accepted

Answered
Is there a way to count the number of sequential values in a vector?
Here is a two-step suggestion: 1. set all the single 1's to 0 2. find the indices x = [1 0 1 1 1 0 0 1 0 1 1] % data i...

12 years ago | 0

Answered
Changing XDir permanent to reverse
Why not set the direction AFTER all the plot commands?

12 years ago | 1

Answered
How to do that.the product of four consecutive even integers is 13440. Using Matlab?
One approach is to use brute force: N = 13440 ; for k = 2:N v = k + [0:2:6] ; p = prod(v) ; if ...

12 years ago | 1

| accepted

Answered
Populate Array with duplicate variables
Another ML-trick: % data x = [1 4 3 6] ; n = 2 ; % engine y = kron(x,ones(1,n))

12 years ago | 1

Answered
How do I create a vector combinations in pairs
The simplest way is to create all N*N combinations and weed out the N ones that have the same value. N = 4 ; A = 1:N ; ...

12 years ago | 0

Answered
in an image of size 256 by 256,what is the command to retrieve the value of the pixel (3,4)
PixelValue = ImageArray(3,4) or if your image is actually having the size 256x256x3 PixelValueRGB = ImageArray(3,4,:) ...

12 years ago | 0

| accepted

Answered
Combining two strings to a common string
The easiest, and most user-friendly, way is, indeed to use for-loops. However, you can make advantage of the built-in function S...

12 years ago | 0

Answered
How to create a specific matrix from a regular matrix
Just for fun and to show the power of logical indexing: A = reshape(1:12,3,[]).' % input [m,n] = size(A) ; tmp = ...

12 years ago | 0

Answered
how to stop for loop?
help break

13 years ago | 0

| accepted

Answered
How to slipt an image into equal & non-overlapping 2*2 matrixes in matlab?
To access the contents of a cell you need to use curly braces C = { magic(2) ; 3*magic(2)} ; C1 = C(1) C2 = C{1} ...

13 years ago | 0

Load more