Answered
How to repeat an array based on another array
For MATLAB before R2015a: >> A = [1,2,3,4]; >> B = [2,3,1,2]; >> cell2mat(arrayfun(@(a,b)repmat(a,1,b),A,B,'uni',0)) ...

10 years ago | 0

Answered
I have a picture many in folder
<https://www.mathworks.com/matlabcentral/answers/57446-faq-how-can-i-process-a-sequence-of-files> <http://matlab.wikia.com/wi...

10 years ago | 1

| accepted

Answered
create a new matrix with interval and assign strings in front of them
>> A = [1;0;2]; >> range = 4; >> step = 2; >> M = bsxfun(@plus,A,-range:step:range) M = -3 -1 1 3 5...

10 years ago | 0

| accepted

Answered
Function "fix" with numbers/characters
*Command syntax* (all words are strings, each space separates input arguments): fix 5.4 is equivalent to writing this: ...

10 years ago | 0

Answered
exclude the maximum value per column
This will remove the first maximum value from each row: >> M = randi(9,6,9) M = 3 9 1 1 1 1 5 2 3 ...

10 years ago | 1

| accepted

Answered
difference between command and function
There is no difference between functions and commands, the terms can be used to refer to the same functionality, the only differ...

10 years ago | 1

Answered
Prevent MATLAB from creating empty mfile if it doesn't exist
After CTRL+D you click "no" instead of "yes": <</matlabcentral/answers/uploaded_files/67503/Capture.PNG>> If at some point...

10 years ago | 6

| accepted

Answered
How can I change 10x2 cell array to 1x10cell array of [1x2 double]?
This simple line does exactly what you want: exon = num2cell(cell2mat([exon_starts,exon_ends]),2)' giving >> exon{1} ...

10 years ago | 0

| accepted

Answered
Either I or matlab is going crazy with vertcat using brackets
MATLAB is doing exactly as documented: <https://www.mathworks.com/help/matlab/matlab_prog/case-and-space-sensitivity.html> ...

10 years ago | 2

| accepted

Answered
How to index and replace
|totalGrade| is already the index (values from one to five) that can be used directly into |letters|, therefore you do not need ...

10 years ago | 1

| accepted

Answered
How to extract unique values in one column per groups of rows in other column
Assuming sequential integers starting from one in the first column: >> accumarray(M(:,1),M(:,2),[],@(n)numel(unique(n))) a...

10 years ago | 1

| accepted

Answered
interp1 using method 'previous' returns an unexpected NaN?
This is clearly explained in the <https://www.mathworks.com/help/matlab/ref/interp1.html |interp1|> documentation, in the sectio...

10 years ago | 2

| accepted

Answered
I have a cell array that it has number and character. The first part of the cell inlcludes numbers but the the length is varying. The second part is always a letter, but it can vary.I am going to dived numbers and the letter.
Here are two simple methods. It is easy to use <https://www.mathworks.com/help/matlab/ref/regexpi.html |regexp|> to achieve t...

10 years ago | 2

| accepted

Answered
turn data of the form :"Year, Number of day(0 to 364) ,Hour(0 to 23)" into a date variable for matlab.
For MATLAB releases without |datetime| (i.e. pre R2014b), converting this via <https://www.mathworks.com/help/matlab/ref/datestr...

10 years ago | 0

Answered
changing the location of num2str
Add an offset to the x (and/or y) location: d = 0.01; text(x(i)+d,y(i),num2str(i)) Remember that x and y are data uni...

10 years ago | 0

| accepted

Answered
Loading a Variable with its Original Format
C = load( ‘A.mat’, ‘B’); B = C.B; Note that you do not actually need to assign the variable B. Instead you can simply acce...

10 years ago | 0

| accepted

Answered
How can I read in specific cells which contain file names ending in 'Pressure.mat'?
Do not use ugly loops to do this. MATLAB is much more beautiful than that! Do not use |strfind| to do this: it will match tha...

10 years ago | 0

Answered
I have a matrix A how to add 1 to every odd num in it
>> A = randi(9,5) A = 7 7 8 4 5 7 1 7 4 5 4 3 3 7 6...

10 years ago | 0

Answered
customizing point names in matlab
Note that you might like to add some space between the points and the text: X = rand(5,1) ; Y = rand(5,1) ; plot(X,Y,...

10 years ago | 1

Answered
What is the syntax to plot a graph with sequential number labels instead of letters?
strsplit(sprintf('%d\n',6:20)) You will find more useful <https://www.mathworks.com/help/matlab/ref/sprintf.html |sprintf|> ...

10 years ago | 0

| accepted

Answered
Error in sub2ind at line 43 when attempting to analyze more than one blob extracted from image.
The error message seems quite clear to me: you are asking for a subscript that it not within the requested matrix size. Basicall...

10 years ago | 1

| accepted

Answered
Separate rows that contain certain string character
>> idx = cellfun(@(s)'B'==s(end),a(:,3)); >> c = a(idx,:) You could even put this in a function: >> fun = @(c)a(cellfu...

10 years ago | 0

| accepted

Answered
How to shrink Matrix eg. 10830:21600 -> 361:576
If you want to interpolate (i.e. estimate values based on a fitted curve) then use one of the interpolation tools: <https://w...

10 years ago | 1

Answered
I cant find the error in there. can you help me
This might be a spelling mistake, perhaps you meant to write |reflect_collision|. Otherwise you will need to make sure that ...

10 years ago | 1

| accepted

Answered
The matrices rgb and imag1 have same values,same dimensions but different class.But while displaying images imag1 and rgb are different.Why is it so?
_"Why is it so?"_ Because the different classes get treated differently. The output from |imread| is (most likely) of clas...

10 years ago | 0

Answered
how can i start learning matlab?
Did you learn to ride a bicycle by reading books? Why read books when you can actually start practicing using MATLAB? The ...

10 years ago | 1

Answered
Plotting in the same graph
The simplest way is to call <https://www.mathworks.com/help/matlab/ref/hold.html |hold on|> between the two plot calls: plot...

10 years ago | 0

Answered
why do not white pixels equal black pixels
Both your assumptions and your code are wrong. The pixels are not exclusively black or white, because there are also many many g...

10 years ago | 0

| accepted

Answered
How to extract cell element from a multi-dimensional cell?
cellfun({@(c)c(1,3),respPreStore) or cellfun({@(c)c{1,3},respPreStore,'UniformOutput',false)

10 years ago | 0

| accepted

Answered
How can I split a string and assign new values to the strings?
Using indexing means no loops and a very memory-efficient method: >> str = 'Hello World!'; >> tmp = num2cell(str); >>...

10 years ago | 0

Load more