Answered
Reference to a cleared variable seg_result.
This is a classic example of why it is a very bad idea to call |load| _without assigning its output to a variable_. It also show...

10 years ago | 0

| accepted

Answered
how select random elements of array without replacement
The easiest way to do this is to use <http://www.mathworks.com/help/matlab/ref/randperm.html |randperm|>: this provides a random...

10 years ago | 1

| accepted

Answered
How to split or divide a larger array in to the predetermined size?
You can use <http://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|> to put contiguous groups of non-zeros into o...

10 years ago | 0

| accepted

Answered
Can you give me an example about writing file by the memmapfile function ? think you very much.
Here is the first example from the <http://de.mathworks.com/help/matlab/ref/memmapfile.html |memmapfile|> documentation, with on...

10 years ago | 0

Answered
Acquire images in loop and save as different name
Simply put the frames into a cell array: C = {}; for ... % your loop C{end+1} = snapshot(...); end And then use...

10 years ago | 0

| accepted

Answered
How can I add components of a vector given conditions from another vector of different dimensions?
This is fast and easy to solve by using a simple <http://www.mathworks.com/help/matlab/ref/mtimes.html |mtimes|>. Your data (...

10 years ago | 0

| accepted

Answered
How can I use an answer from a prompt as a file name?
Try this: [~,name] = fileparts(input(prompt1,'s')); writetable(centroiddata, [name,'.txt'])

10 years ago | 0

| accepted

Answered
Does the matlab version affect on your code's output ?
Yes. * Some MATLAB versions changed the order of results (for an example see <http://www.mathworks.com/help/matlab/ref/unique...

10 years ago | 2

| accepted

Answered
How can i write any vector into short form?
You could use Jan Simon's excellent FEX submission <http://www.mathworks.com/matlabcentral/fileexchange/41813-runlength RunLengt...

10 years ago | 0

| accepted

Answered
Hi,i want to use a for loop in order to solve the sum of all result that obtain in the any step , can any one help me?
Don't waste time using a loop! Just write efficient <http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html vectori...

10 years ago | 0

Answered
How to get textscan working with YY-MM-DD data?
According to the <http://www.mathworks.com/help/matlab/ref/datetime-properties.html datetime properties> linked to from the <www...

10 years ago | 0

| accepted

Answered
create multiple figures of patches with random colors
N = 12; vec = 'ymcrgbk'; clr = vec(randi(numel(vec),N)); figure for k = 1:N X = [0,2,2,0]+k; Y = [0,...

10 years ago | 0

| accepted

Answered
Rows mean collapse in big matrix
If the number of rows of |M| was an integer multiple of |N| then this would be easy to achieve by simply reshaping the matrix |M...

10 years ago | 1

| accepted

Answered
Cell and Mat problem
You can use <http://www.mathworks.com/help/matlab/ref/blkdiag.html |blkdiag|>: >> A = [1,2;5,2]; >> B = [2,1;4,5]; >>...

10 years ago | 1

| accepted

Answered
element by element subtraction using bsxfun
This works for an array whatever its size: >> A = [1 2 3; 4 5 6; 7 8 9] A = 1 2 3 4 5 6 ...

10 years ago | 0

| accepted

Answered
How to erase the diagonal elements of a matrix (in one line)?
I know that this violates the "one line" requirement, but a transpose makes the task easy: >> X = [1,2,3;4,5,6;7,8,9] X ...

10 years ago | 4

| accepted

Answered
How can I save the contents of a struct to a .mat file?
*Solution* This is exactly what <http://www.mathworks.com/help/matlab/ref/load.html |load|> does when it has an output variab...

10 years ago | 5

| accepted

Answered
How to sum strings digits?
Use John D'Errico's excellent FEX submission, Variable Precision Integer Arithmetic: <http://www.mathworks.com/matlabcentral...

10 years ago | 1

| accepted

Answered
Is there a way to extract specific fields from a structure?
*Solution* >> S.a = 'Hello'; >> S.b = 'World'; >> C = {'a','b'}; >> D = cellfun(@(f)getfield(S,f),C,'UniformOutput...

10 years ago | 0

| accepted

Answered
How can I read a .ras file?
Just use the inbuilt <http://www.mathworks.com/help/matlab/ref/imread.html |imread|> function, as it supports the SUN Raster fil...

10 years ago | 0

Answered
numbering of matrices generation
>> A = randi(9,3,1) A = 6 5 9 >> B1 = A([1,1],1) B1 = 6 6 >> B2 = A([2,2],1) B2 = 5 ...

10 years ago | 0

Answered
finding a string with parentheses using regexp
find(~cellfun(@isempty,regexp(A,'\(P\)'))); Explanation: parentheses are special characters in regular expressions, and need...

10 years ago | 2

| accepted

Answered
how to count non nan values
nnz(~isnan(vec)) where |vec| is the vector (it could even be a matrix or ND array).

10 years ago | 5

| accepted

Answered
How o add apostrophe (') in a char or string array
You need to escape the apostrophe by using it twice: >> '''hello''' ans = 'hello' >> sprintf('''%s''','hello') a...

10 years ago | 3

| accepted

Answered
matrix matching w.r.t row
You can use <http://www.mathworks.com/help/matlab/ref/ismember.html |ismember|> with the |rows| option: >> idx = ismember(m...

10 years ago | 0

| accepted

Answered
How to vectorize matrixvector multiplications with previous-dependent input?
Most of the operations can be moved out of the loop: t = ones(2,K); B = [cos(Fi),-sin(Fi);sin(Fi),cos(Fi)]; for k = 2...

10 years ago | 0

Answered
Use matfile for structure data
If the order of the fields is so important, then you can sort them yourself: <http://www.mathworks.com/help/matlab/ref/orderf...

10 years ago | 0

Answered
How to label axis in confusion matrix ?
M = [3,0,0;1,2,0;0,0,3]; L = {'A','B','C'}; X = [L(:),num2cell(M,2)]'; fprintf(' %3s %3s %3s\n',L{:}) fprintf('...

10 years ago | 0

Answered
How to check which function is the slowest one?
This is covered extremely well in the documentation: <http://www.mathworks.com/help/matlab/matlab_prog/profiling-for-improvin...

10 years ago | 0

Answered
How do I make a new variable made up of specific row from other variables?
*Learn to use indices!* Do you see your numbered variables? Do you see that each number in its names acts like an index, tell...

10 years ago | 1

| accepted

Load more