Risposto
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 ...

quasi 11 anni fa | 0

| accettato

Risposto
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...

quasi 11 anni fa | 0

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

quasi 11 anni fa | 0

Risposto
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...

quasi 11 anni fa | 0

Risposto
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...

quasi 11 anni fa | 1

Risposto
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...

quasi 11 anni fa | 0

Risposto
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)

quasi 11 anni fa | 8

Risposto
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(...

quasi 11 anni fa | 1

| accettato

Risposto
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) ...

circa 11 anni fa | 1

| accettato

Risposto
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 ...

circa 11 anni fa | 0

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

circa 11 anni fa | 0

Risposto
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{:})

circa 11 anni fa | 1

Risposto
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...

circa 11 anni fa | 0

| accettato

Risposto
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 ...

circa 11 anni fa | 0

Risposto
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 ./ ...

circa 11 anni fa | 1

Risposto
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...

circa 11 anni fa | 0

| accettato

Risposto
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(@(...

circa 11 anni fa | 0

Risposto
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...

circa 11 anni fa | 0

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

circa 11 anni fa | 0

Risposto
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...

oltre 11 anni fa | 1

Risposto
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. ...

oltre 11 anni fa | 0

Risposto
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'} ...

oltre 11 anni fa | 8

Risposto
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)

oltre 11 anni fa | 1

Risposto
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...

oltre 11 anni fa | 6

| accettato

Risposto
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...

oltre 11 anni fa | 0

Risposto
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...

oltre 11 anni fa | 0

| accettato

Risposto
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...

oltre 11 anni fa | 3

Risposto
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

oltre 11 anni fa | 0

Risposto
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...

oltre 11 anni fa | 0

Risposto
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...

oltre 11 anni fa | 0

Carica altro