回答済み
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 ...

11年弱 前 | 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 ./ ...

11年弱 前 | 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...

11年弱 前 | 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(@(...

11年弱 前 | 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...

11年弱 前 | 0

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

11年弱 前 | 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...

11年弱 前 | 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. ...

11年弱 前 | 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'} ...

11年弱 前 | 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)

約11年 前 | 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...

約11年 前 | 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...

約11年 前 | 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

さらに読み込む