Answered
Why \n or newline doesn't work ?
"Do someone know why ?" The documentation states "For character array inputs, strcat removes trailing ASCII white-space charact...

11 days ago | 0

| accepted

Answered
Access multiple structure fields and put them in a new structure or vector
No, what you are asking for is not possible. This syntax: dataArray{1,2:10} creates a comma-separated list of separate arrays,...

13 days ago | 0

| accepted

Answered
Append to vector of different sizes in for loop
Simpler: S = load('test_file.mat') fun = @(b,e)S.TimeSeries_short(b:e); out = arrayfun(fun,S.ipts(1:2:end),S.ipts(2:2:end),'u...

13 days ago | 0

| accepted

Answered
i have loop and i need to Create a table for each loop
Use indexing rather than numbering the variables: N = the number of tables that you want C = cell(1,N); for k = 1:N C{k} ...

13 days ago | 0

| accepted

Answered
how to append matrix in a loop
s1 = [1,0,1,1,0]; s2 = [2,4,3,1,2]; v = repelem(s1,s2)

13 days ago | 0

Answered
How to combine to identical 'for' loops with sequential varying variables ?
Numbering variables like that is completely the wrong approach and should be avoided. One better approach is to use a container...

13 days ago | 0

| accepted

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(...

16 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+^$'); ...

17 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...

17 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)

18 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...

18 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...

19 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)

19 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...

19 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.'))

20 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...

20 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...

20 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...

24 days ago | 0

| accepted

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

24 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...

24 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...

24 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...

24 days ago | 0

| accepted

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

25 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 ...

25 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...

25 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 ...

26 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')

26 days ago | 0

| accepted

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

26 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)

26 days ago | 1

Load more