Answered
How to sum up a few numbers in sequence and save as a separate matrix
Here is an algorithm: A = [0; 0; -1; -2; -1; 0; 0; 0; -2; -1; 0] % input B = cumsum(A) tf = diff([A==0 ; true])==1 ...

10 years ago | 0

| accepted

Answered
What is the best way to handle missing data?
You can take a look at the functions *nanmean*, *nanstd* and the like (available in the Statistics Toolbox). You can also thr...

10 years ago | 0

Answered
Repeat elements in a 2D vector
OutImage = imresize(InImage, 2, 'nearest')

10 years ago | 0

Answered
How can I plot x and y error bars and also calculate the equation of the line?
help polyfit and take a look at <http://www.mathworks.com/matlabcentral/fileexchange/3963-herrorbar HERRORBAR on the File Exc...

10 years ago | 0

Answered
Comparing two cell arrays of strings of different sizes
assuming B is all unique A = {'X_ABCDE' ; 'X_BCDEA' ; 'X_BCE'} B = {'X_A' ; 'X_B'} index = arrayfun(@(k) find(strncmp...

10 years ago | 1

Answered
Can we do polyfit on matrix?
A loop is the most obvious choice. You can hide the loop using arrayfun FitFH = @(k) polyfit(X(:,k), Y(:,k), 1) P = arra...

10 years ago | 0

Answered
how to remove the first 5 characters from a cell array 343x1 cell
If A is your cell-array of strings, this oneliner will do the job: B = cellfun(@(x) x(1:end-5), A, 'un', 0)

10 years ago | 8

Answered
How to randomly generate an integer which is unique during multiple iterations
You can use the function randperm for this: N = 10 R = randperm(N) for k=1:N Current_Random_Integer = R(...

10 years ago | 1

| accepted

Answered
Help in naming the file from 001 to 100 with the same extenstion
% assuming you are in the directory of choice extension = 'jpg' DF = dir(['*.' extension]) for k = 1:numel(DF) ...

10 years ago | 1

| accepted

Answered
Finding averages in an array
As a beginner, you're better of to write out each individual step of the process in detail Is2002Game = X(:,3)==2002 ...

10 years ago | 0

Answered
how many ways to arrange numbers from 1-3?
You might also be interested in PERMN: <http://www.mathworks.com/matlabcentral/fileexchange/7147>

10 years ago | 0

Answered
I have 3*1 matrix in form of cell or string. I have to convert into mat. i have to convert into 3*1*20
You can use comma-separated list expansion: mat = cat(1, Tcur{:})

10 years ago | 1

Answered
Is there any alternative in matlab like Goto statement in C?. If so, can you please help me how to implement the given code in matlab.
This is exactly why the use of goto is ill-advised! It creates spaghetti code that is very hard to debug, translate, or read, as...

10 years ago | 0

| accepted

Answered
Splitting a vector into 'on' periods
% A one-liner, works when vector only contains values as in the example: vector = [1 2 3 4 0 0 0 0 5 6 7 4 7 8 0 0 0 1 2 5 ...

10 years ago | 0

Answered
Help with the matrix creation pls ? if possible not a hardcoded solution but a function .
% brute force A = [] ; for k=0:10 for j=0:10-k A(end+1,:) = [k, j 10-k-j] ; end end A = A ./ ...

10 years ago | 1

Answered
find the difference of two structure elements
help setdiff First put the names of the files into a cell array. A = {daq_files.name} ; B = {TCdaq_files.name} ; U...

10 years ago | 0

| accepted

Answered
Find the index of nonempty array in a structure for a particular field
use ARRAYFUN % create some data for j=1:10, select(j).c = repmat(j,round(rand(1))) ; end % engine tf = arrayfun(@(...

10 years ago | 0

Answered
How to divide an image into non-overlapping blocks size 4x4?
What about using the dedicated tool BLOCKPROC (provided you have the Image Processing Toolbox) which gives the following one-lin...

10 years ago | 0

Answered
How to find the day number of any year from a date?
help datenum and then use simple subtraction

10 years ago | 0

Answered
Hello can somebody tell me what I am doing wrong?
This is a working for-loop, which prints out something that resembles your goal: a = input('Enter the Array:'); for i...

10 years ago | 1

Answered
Matrix with one numbers column and one strings column.
You can use cell arrays for this, which can hold a mixture of types. Each cell contains something, possibly another cell array. ...

10 years ago | 0

Answered
Sorting an array of strings based on number pattern
Here is a way: % create some example names filenames = {'xx_1_yy.txt','xx_8_yy.txt','xx_10_yy.txt','xx_2_yy.txt'} ...

10 years ago | 8

Answered
How to display all this in a single msgbox?
To show multiple lines in a msgbox, use a cell array: C{1} = 'Hello' ; C{2} = sprintf('N = %d',10) ; msgbox(C)

10 years ago | 1

Answered
combine columns with different lengths to create a matrix
Many years ago, I wrote the function PADCAT to accomplish this. You can find it on the Matlab File Exchange: <http://www.math...

10 years ago | 6

| accepted

Answered
Performing equations on individual elements of a 3D Matrix, and then summing that along the z column
What type of equation are you talking about? This might get you started Z = zeros(size(A)) ; Z(A==0) = 2 % simple equ...

10 years ago | 0

Answered
How to put cell array in sprintf?
Use comma-separated list expansion. And you need to specify the format only once (see help fprintf) A = {1 2 3 4} sprint...

11 years ago | 0

| accepted

Answered
Is it possible to make larger gap between xlabel and the x-axes?
You can use SET and GET: xh = get(gca,'xlabel') % handle to the label object p = get(xh,'position') % get the current po...

11 years ago | 3

Answered
keep first time a value appear in a colomn and replace following ones
This will keep the first zero in each row of A and replace every following zero with one: A(A==0 & cumsum(A==0,2)>1) = 1

11 years ago | 0

Answered
precision problem in simple subtraction?!?
Simple for you, but not for a computer! Using only binary representations and a limited memory system a computer cannot store nu...

11 years ago | 0

Answered
Efficient method for finding index of closest value in very large array for a very large amount of examples
I point you to my NEARESTPOINT function, available on the File Exchange: <http://www.mathworks.com/matlabcentral/fileexchange...

11 years ago | 0

Load more