Réponse apportée
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 ...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
Repeat elements in a 2D vector
OutImage = imresize(InImage, 2, 'nearest')

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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...

plus de 10 ans il y a | 1

Réponse apportée
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...

plus de 10 ans il y a | 0

Réponse apportée
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)

plus de 10 ans il y a | 8

Réponse apportée
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(...

plus de 10 ans il y a | 1

| A accepté

Réponse apportée
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) ...

plus de 10 ans il y a | 1

| A accepté

Réponse apportée
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 ...

plus de 10 ans il y a | 0

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

plus de 10 ans il y a | 0

Réponse apportée
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{:})

plus de 10 ans il y a | 1

Réponse apportée
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...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
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 ...

plus de 10 ans il y a | 0

Réponse apportée
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 ./ ...

plus de 10 ans il y a | 1

Réponse apportée
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...

presque 11 ans il y a | 0

| A accepté

Réponse apportée
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(@(...

presque 11 ans il y a | 0

Réponse apportée
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...

presque 11 ans il y a | 0

Réponse apportée
How to find the day number of any year from a date?
help datenum and then use simple subtraction

presque 11 ans il y a | 0

Réponse apportée
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...

presque 11 ans il y a | 1

Réponse apportée
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. ...

presque 11 ans il y a | 0

Réponse apportée
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'} ...

presque 11 ans il y a | 8

Réponse apportée
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)

presque 11 ans il y a | 1

Réponse apportée
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...

presque 11 ans il y a | 6

| A accepté

Réponse apportée
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...

presque 11 ans il y a | 0

Réponse apportée
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...

presque 11 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 11 ans il y a | 3

Réponse apportée
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

presque 11 ans il y a | 0

Réponse apportée
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...

presque 11 ans il y a | 0

Réponse apportée
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...

presque 11 ans il y a | 0

Charger plus