Answered
dynamic subindices <-> linear indices conversion, data crop /trim
*Method one: comma-separated list:* many MATLAB users don't realize that indices can be provided as a <https://www.mathworks.com...

8 years ago | 1

| accepted

Answered
Operating on One Column Based on Another
You should look into <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> A = [1;1;1;1;2;2;2;3;3;3;...

8 years ago | 1

| accepted

Answered
I have a char array with code numbers separated by full stops and I want to extract all and save them in a single cell inside a matrix.
Using <https://www.mathworks.com/help/matlab/ref/regexp.html |regexp|>: >> C = regexp(TempUid,'\d+\.','match'); >> C{:} ...

8 years ago | 0

| accepted

Answered
How to create all possible combinations in MATLAB
Download Jos's excellent <https://www.mathworks.com/matlabcentral/fileexchange/10064-allcomb-varargin- |allcomb|>, and simply us...

8 years ago | 2

| accepted

Answered
Creating a matrix with for loop
_"It should definitely be a for loop. I don't think such a matrix can be produced using for loop"_ Using <https://www.mathwor...

8 years ago | 0

| accepted

Answered
Hi Everbody.. I am trying to make a piece of code what will make 20 maps automatically number from 1 to 20.......
for k = 1:20 dnm = sprintf('newdir_%d',k); mkdir(dnm) end

8 years ago | 0

| accepted

Answered
sprintf: how to efficiently create a string of 75 numbers, separated by comma
_"I need an efficient way to do it when there are many entries in A."_ This is probably about the most efficient way: A ...

8 years ago | 0

Answered
How do I load multiple .dat files in matlab?
_"How do I load multiple .dat files in matlab?"_ Just follow the advice given in the MATLAB documentation. It shows two metho...

8 years ago | 0

| accepted

Answered
How do i get the output for each iteration of code?
By using indexing. Indexing is a basic concept that is shown in the introductory tutorials: <https://www.mathworks.com/help/m...

8 years ago | 0

| accepted

Answered
How to compare two vectors and output the index?
This is easy in just two lines using <https://www.mathworks.com/help/matlab/ref/find.html |find|> and <https://www.mathworks.com...

8 years ago | 0

| accepted

Answered
How to load same/common variables from multiple file without overwriting the previous values
Use a cell array and indexing: data = cell(N,1); for k = 1:N data{k} = load(matfiles(k).name); end

8 years ago | 0

| accepted

Answered
How to generate several matrix by varying one value?
A = [0,0,0,30;70,30,0,0;30,70,0,0;30,0,70,0]; B = [1;2;3;4]; vec = 10:15; out = cell(size(vec)); for k = 1:numel(v...

8 years ago | 0

| accepted

Answered
Can MATLAB duplicate cell array entries without creating cell within cells?
Using <https://www.mathworks.com/help/matlab/ref/repelem.html |repelem|> is much simpler: data = {'ALC238Tires'; 'ALC01A1RI...

8 years ago | 0

| accepted

Answered
Convert 1x1x6381 double to 6381x1 double?
If |A| is your array, then this will convert it into a column vector, regardless of its original size: A(:) See: <https:...

8 years ago | 1

| accepted

Answered
Interpolation of 2D matrix using Interp2 to eliminate NaN
_"How do I correct it? Thanks."_ NaN data is missing data, so although you think that you have gridded data in reality you do...

8 years ago | 1

| accepted

Answered
create string of characters from variable name matlab
You could use <https://www.mathworks.com/help/matlab/ref/inputname.html |inputname|>: function FeatureExtract(signal,numOfw...

8 years ago | 2

| accepted

Answered
Cumulative sum of groups
>> data = [1,1;1,0;1,1;2,0;2,1;2,1;3,0;3,1;3,0]; >> C = accumarray(data(:,1),data(:,2),[],@(v){cumsum(v)}); >> [data,ver...

8 years ago | 1

| accepted

Answered
Concatenation of columns of several cell Arrays
You used the wrong brackets. You used curly braces to get the contents of the cells of |A|, but not with |B|. All you need is t...

8 years ago | 1

| accepted

Answered
Creating a cell array
Simpler using direct allocation, and does not return nested cell arrays: N = 10 ; C = cell(N,3) ; for k = 1:N ...

8 years ago | 0

Answered
Use of loops to print the contents of a cell array with varying number of rows
No loops are required, just <https://www.mathworks.com/help/matlab/ref/transpose.html transpose> the cell array and use a <https...

8 years ago | 0

Answered
Extrapolation/error handling
I am guessing that |v| is non-scalar, in which case you will need to use |any|: if any(v<2 | v>200)

8 years ago | 1

| accepted

Answered
How to keep looping a switch statement?
str = ''; while ~strcmp(str,'stop') ... str = ... end

8 years ago | 0

Answered
How to unpack contents of a cell array?
You can use a comma-separated list, and simply concatenate the contents into one matrix: mat = vertcat(dom_psth_tb{:}) Read th...

8 years ago | 3

| accepted

Answered
Using fscanf to make a matrix from text file?
_"This outputs the correct matrix, except it is giving by rounded decimals multiplied my an exponential. "_ Your data has bee...

8 years ago | 0

Answered
How to change a numeral of a number?
If you have char vector/array: >> str = '543.32145'; >> str(end) = '0' str = 543.32140 If you have numeric values:...

8 years ago | 1

Answered
Is there any way to convert variables from list to arrays?
Simply store the data in *one* structure, and then it is trivially easy (no slow, buggy |eval| is required): >> S.a = [1,2,...

8 years ago | 1

| accepted

Answered
Accumarray help: extracting matrix min/max based on values in first column.
Why not just calculate the min/max directly using |accumarray|?: [~,~,idx] = unique(matrix(:,1)); accumarray(idx,matrix(...

8 years ago | 1

Answered
Analyse files in a different folder than current folder
You need to give |dir| the folder path, otherwise it will just look in the current directory: foldername = handles.folderna...

8 years ago | 0

| accepted

Load more