Answered
In a specific range, finding the first value over a specific value and maximum value
With these sort of setup, what you want to do is break up your vector into smaller vectors corresponding to the individual seque...

11 years ago | 0

Answered
gather data from different sections of each column
totmods = 10000; numselect = 1000; A = reshape(1:100*totmods, 100, totmods); B = randi(size(A, 1) - 9, numsel...

11 years ago | 1

Answered
Finding x value of local extrama
The second return value of <http://www.mathworks.com/help/releases/R2015b/matlab/ref/max.html |max|> is the index at which this ...

11 years ago | 0

Answered
Find prefix and postfix in a string
You can't have a regex that returns the before and after of a sequence of characters without that sequence of characters, but yo...

11 years ago | 1

| accepted

Answered
putting a subscript into a string, displaying the command window
It is not possible to display subscripts or superscripts in the command window. The java text control that matlab uses does not ...

11 years ago | 0

Answered
Finding all possible combinations of a matrix
This will work as long as |mat| has less than 10 rows: assert(size(mat, 1) < 10, 'mat has too many rows') rowidx = dec2b...

11 years ago | 0

Answered
How can I find the top 5% values' index in a 3D matrix
demodata = rand(100, 50, 20); %a 3d matrix; [values, idx] = sort(demodata, 'descend'); %depending on what is meant by to...

11 years ago | 0

Answered
changing values of pixels in an image pixel by pixel (image in .jpeg format)
im = imread('yourimage.jpg'); im(im == 255) = 249; %assume the image is indeed greyscale. No guarantee with jpg imwrite(...

11 years ago | 0

| accepted

Answered
Import too large csv data file with strings
No matter what, you're bound by the reading speed of matlab. Probably the fastest way to read the file is to rea it all once wit...

11 years ago | 0

| accepted

Answered
How can I shift and repeat an element within a matrix?
Another option is to use |eye|: idx = 3; n = 6; res = [zeros(idx-1, 1), fliplr(eye(idx-1)), zeros(idx-1, n-idx); eye(...

11 years ago | 0

Answered
division of two matrices
<http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|> is exactly designed for this: A = [1 1; 2 1; ...

11 years ago | 1

Answered
Sort one set of data to correspond to another.
Following your comment to Thorsten's answer, use the 2nd return value of <http://www.mathworks.com/help/matlab/ref/ismember.html...

11 years ago | 0

Answered
Search rows of a matrix on another
There is no search involved. It's simple matrix indexing: A = [2 3 5; 1 2 4; 7 8 10]; T = [200; 500; 750...

11 years ago | 0

| accepted

Answered
why I get "out of memory" error when i use zeros(60000)?
|zeros(60000)| is the same as zeros(60000, 60000) A 60,000 x 60,000 matrix of doubles requires approximately 27 GB of me...

11 years ago | 1

Solved


What's the missing interior angle?
I'm talking about polygons... The sum of the interior angles of a triangle is 180 degrees. The sum of the interior angles of a...

11 years ago

Answered
To calculate portfolio returns
If you want to treat the NaNs as zero, make them zero: r(isnan(r)) = 0; Your calculation is then simply R = [NaN; s...

11 years ago | 0

| accepted

Answered
Splitting Characters in A Cell Array
Use the power of <http://www.mathworks.com/help/matlab/matlab_prog/regular-expressions.html Regular Expressions>. It's a dauntin...

11 years ago | 3

Answered
Find common files in two directories
There is reason behind your regexp returning a cell array of cell array of cell array. The outer cell array is simply because yo...

11 years ago | 1

| accepted

Answered
finding most common letter in a bunch of words
Two steps are required: # build the histogram of the letters, however you want (using |accumarray|, |histc| or |histcounts|) ...

11 years ago | 0

Answered
Replace values of one column of matrix size 1*n to another matrix of size n*n
A = [.01 0 0 0 .42 0 0 0 .13 0 0 0 .09 0 0 .32]; B = repmat([.12 .18 .08 .17 .43 .13 .13 .24 .09 .11 .04 .08 .10 .15 .08 .4...

11 years ago | 0

| accepted

Answered
listing/enumerating numbers
Simply use <http://www.mathworks.com/help/releases/ref/accumarray.html |accumarray|>: interact = [1 2; 1 3; 2 1; 2 3; 3 1; ...

11 years ago | 0

Answered
removing strings on several calls of function
Simply pass in the vowel list to your function and return the shortened list as an output. On the next call to your function you...

11 years ago | 1

Answered
Vectorization of a for loop
Well, |P(k+1)-P(k)| can be obtained in a vectorised way with the |diff| function, so, assuming that by default |B(k)| is zero: ...

11 years ago | 0

Answered
how to solve piece-wise function?
That function has a name, it's the signum function, called <http://www.mathworks.com/help/matlab/ref/sign.html |sign|> in matlab...

11 years ago | 1

Answered
Find char consecutive in a string
Thanks for clarifying. You still haven't my answered my question about whether or not a character can be part of several matches...

11 years ago | 1

| accepted

Answered
if statement for string
Use <http://www.mathworks.com/help/matlab/ref/ismember.html |ismember|>: if ismember(letter, word) %do something el...

11 years ago | 0

| accepted

Answered
xlsread to an array by user input with interpolation
Use <http://www.mathworks.com/help/releases/ref/interp1.html |interp1|> to get your temperature, enthalpy and entropy for both P...

11 years ago | 0

Answered
How do I make this into a loop function?
See this <http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Answer in the FAQ> on processing a sequence ...

11 years ago | 0

Answered
rearranging the ind2sub result
You can't get |ind2sub| to return values in a different order but you can |sort| the values afterward: [r, c] = ind2sub(siz...

11 years ago | 0

Answered
create an array of single struct
_"If I do s1(1) it returns a1."_ No, it also returns a structure. Both |s1| and |structElement| are arrays of a single struct...

11 years ago | 1

| accepted

Load more