Answered
for loop with vectors having different sizes
a = {[1,2],[3,4,5]}; p = {[6,7],[8,9,10,11]}; c = 'trial'; for k1 = 1:numel(a) for k2 = 1:numel(p) s = sprintf(...

14 days ago | 0

Answered
using natsortfiles to import csv files correctly
Taking a guess that you actually want to match the last integer, not just the last digit: C = natsortfiles({S.name},'\d+^$'); ...

15 days ago | 0

Answered
Read multiple .CSV files with csvread using a loop
V = 0:4; N = numel(V); C = cell(1,N); for k = 1:N F = sprintf('droplet.%d.csv',V(k)); C{k} = readmatrix(F,'NumHeade...

15 days ago | 0

| accepted

Answered
Convert cell array to matrix with two columns and sort rows by first column value
More robust and more efficient than using cell2mat: M = vertcat(Cell_x{:}); M = sortrows(M,1)

15 days ago | 0

| accepted

Answered
evaluate function handle (determine the value of function handle using my code
Defining lots and lots of function handles is not an efficient approach. One function is much simpler: myfun(30) function hf...

16 days ago | 0

| accepted

Answered
Search/Find sub strings in a string
This matches abbreviations followed by one digit (thus avoiding the Ra/Rag matching problem): C = {'Ra','Bt','Rag','Rg','Vm','S...

16 days ago | 1

Answered
Modify Repmat function to concatenate array
V = [0,1,2,3,4]; n = 3; X = [1,10*(1:n-1)]; Z = kron(X,V)

16 days ago | 0

| accepted

Answered
How to display the Index of a matrix to other corresponding matrices
A = [8,3,5;2,4,6;9,3,4] B = [4,11,5;9,3,2;4,8,1] C = [11,40,3;10,7,5;11,3,60] [v,x] = min(A(:)); B(x) C(x) Or without resh...

17 days ago | 0

| accepted

Answered
How to create a symetric matrix with a vector?
A general solution using indexing: V = [1,2,3,4,5] X = 1:numel(V); M = V(max(X,X.'))

17 days ago | 1

| accepted

Answered
Undefined function 'eq' for input arguments of type 'cell'. Undefined function 'gt' for input arguments of type 'cell'
@ASHU DAYAL CHAURASIYA: the error message clearly tells us what the cause of the error is: one (or both) of the arrays is actual...

18 days ago | 0

Answered
Set default value if no function input given
You did not count the input t when using nargin. You can include the number of inputs before varargin in the logical comparisons...

18 days ago | 0

| accepted

Answered
table in for loop
Just use a cell array: n = 5; C = cell(1,n); for j=1:n x=rand(5,1); y=rand(5,1); C{k} = table(x,y); end Note...

21 days ago | 0

| accepted

Answered
Removing non integer values from an array.
V = [1,23,pi,4,5.6] V(fix(V)~=V) = []

21 days ago | 0

Answered
Call a Function in Another Function, Prepare the Argument as a String
"Is there a general limitation in passing character arrays or strings as input to a function in MATLAB?" No, but the way you ar...

21 days ago | 1

| accepted

Answered
Read Variables with assigned values from excel into Matlab
Note how the file itself contains invalid variable names: they contain space characters which in all of your comments you have s...

21 days ago | 1

| accepted

Answered
Substracting previous value in a matrix and assigning it to a new matrix
a = [ 1.6766 0.6118 0.3707 0.0771 0.0010 0.2057 0.1219 0.2438 2.2065 0.8679 0.4766 0.087...

22 days ago | 0

| accepted

Answered
Findgroups, order of unique values in an array
[ID,~,G] = unique(labels_all,'stable')

22 days ago | 0

| accepted

Answered
Convert matrix to cell knowing the number of components to have in each cell
idx = [2;4;3]; data = [ 0.7922 0.3922 0.9595 0.6555 0.6557 0.1712 0.0357 0.7060 0.8491 ...

23 days ago | 1

| accepted

Answered
storing values of for loop in a matrix
x = -60:0.5:-50; y = -10:0.5:-5; z = nan(numel(x),numel(y)); % better to preallocate array. for i = 1:numel(x) for j = 1...

23 days ago | 0

| accepted

Answered
Can I use logical indexing to find how many times a character is in a string?
You can perform logical comparisons on a character array (they are not very different from numeric arrays): str = 'some random ...

23 days ago | 0

| accepted

Answered
How to quickly obtain the row indices in the original matrix A for a sub-matrix B?
[~,Y] = ismember(B,A,'rows')

23 days ago | 0

| accepted

Answered
Efficient indexing. Index array generating.
data = 1:1000; array1 = 1:10:101 idx = array1(:)+(0:2); out = data(idx)

23 days ago | 0

| accepted

Answered
How can i output an answer when making an app so that it has a set number of decimal places.
sprintf('%.3f',0.07) sprintf('%.3f',1)

23 days ago | 1

Answered
Index exceed the number of array elements
tmp = find(V_ref == V_Target):max(V_ref); for v = reshape(tmp,1,[]);

24 days ago | 0

Answered
Combine each column of two array side by side and add new column to new array
A = [0.6 0.7 0.8; 0.2 0.5 0.25; 0.9 0.7 0.1] B = [11 12 13; 17 18 19; 21 24 26] C = reshape([A;B;A+B],size(A,1),[])

24 days ago | 0

| accepted

Answered
Afficient way to create "sum matrix"
g = 1:3; m = g+g(:)

24 days ago | 0

| accepted

Answered
How to get struct results in a loop?
data(i,:) = FnCarbona(i).ponteiro(); % ^^ indexing needs to specify what happens to all 50 elements.

24 days ago | 0

| accepted

Answered
Extracting specific data from a cell array
After the loop: M = vertcat(A{:}); out = M(:,[9,11])

24 days ago | 0

| accepted

Answered
Save each pair in container.Map to separate variable in .mat file
"Is there a better way to do this?" Of course, just use the -struct option when calling save. Note that conversion to structure...

24 days ago | 1

| accepted

Answered
how to convert cell array to matrix
Where C is your cell array: M = horzcat(C{:}).'

26 days ago | 0

| accepted

Load more