답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
Repeat elements in a 2D vector
OutImage = imresize(InImage, 2, 'nearest')

10년 초과 전 | 0

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 8

답변 있음
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년 초과 전 | 1

| 수락됨

답변 있음
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년 초과 전 | 1

| 수락됨

답변 있음
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년 초과 전 | 0

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

10년 초과 전 | 0

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 0

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

10년 초과 전 | 0

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 8

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 6

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
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년 전 | 0

| 수락됨

답변 있음
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년 전 | 3

답변 있음
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년 전 | 0

답변 있음
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년 전 | 0

답변 있음
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년 전 | 0

더 보기