Community Profile # Stephen23

Active since 2014

Suspensa Vix Via Fit

Professional Interests:

#### Statistics

All
• • • • • • • • • • • • #### Content Feed

View by

Help iteration for loop and tables vertcat
Using one cell array will be much simpler (and more efficient) than your approach of numbering the variable names: w = 1:10; % ...

11 hours ago | 0

Splitting table text column with multiple delimiters based on parantheses.
S = ["Player collected a YELLOW coin at (-5.5, 10.9, 90.1)";"Access to new world";"New world entered";"Player collected a GREEN ...

14 hours ago | 0

How to store multiple output tables in a cell array
With MATLAB it is easier and more versatile to loop over indices, rather than looping over data. This makes it easy to prealloca...

19 hours ago | 0

| accepted

How can I separate the elements of a vector ?
for jj = i(diff(i)~=0) or for jj = unique(i,'stable')

20 hours ago | 0

| accepted

multiplication by taking into account the values when creating a matrix
A = [2,1,4,3;10,15,20,10;20,10,15,20] B = [1,3,4;4,5,6;2,1,4;3,5,1] C = [50;100;25;10] lkp = [10,15,20]; idx = A(1,:); [~,i...

24 hours ago | 1

| accepted

How to read floating point number 5.3246-5 as 5.3246E-5 in text file
str = '9.4345-51.8998772.518305'; tmp = cellstr(reshape(str,8,[]).'); tmp = regexprep(tmp,'(?<=\d)([-+]\d+)\$','E\$1') vec = st...

2 days ago | 0

How to make a two-dimensional mask act on a three-dimensional array?
"I wondered if there was any neat trick to do it by array multipication..." A = 9* ones (6,4,3); % create a 3 dimensional array...

2 days ago | 0

How to create a matrix with special block diagonal structure
N = 8; C = arrayfun(@ones,1:N,'uni',0); B = tril(blkdiag(C{:})); spy(B)

3 days ago | 0

Remove text from CSV data
str = readlines('20220427T131641-2d.csv'); idx = startsWith(str,digitsPattern); writelines(str(idx),'new.csv') Checking: typ...

3 days ago | 0

| accepted

How can I get my function that calculates distance between data and user input with sort data and closest data set from file
V = [2,5,7]; M = readmatrix('somedata.xlsx') D = vecnorm(M-V,2,2) [X,Y] = mink(D,2) Z = M(Y,:)

3 days ago | 0

| accepted

In a 6x6 square matrix A, how to select elements in i-th row with A(i,j) ruled out
A = [0,0,-1,1;1,1,0,0;0,0,1,0;1,-1,0,1] B = +diag(diag(A) & ~any(A-eye(size(A)),2))

3 days ago | 0

convert lower case to upper and upper to lower
str = '123 Hello World!'; str = regexprep(str,'[A-Za-z]+','\${char(mod(\$&-97,64)+65)}')

5 days ago | 0

How can we convert a number into a string value with the exact number of digits present in the number?
sprintf('%.15g',0.0199155) sprintf('%.15g',0.01991556789) sprintf('%.15g',23456.7891234)

8 days ago | 0

| accepted

find first& end of array
S = [0,1,5,2,0,0,0,9,3,50,53,0,0,5,7,4] X = diff([0;S(:)]==0)<0 | diff([S(:);0]==0)>0; V = S(X)

8 days ago | 0

| accepted

separating numbers in cells
Assuming that you have a cell array of character vectors: C = {'1-8','7-1','8-4';'4-6','8-5','7-3'} D = split(C,'-'); A = str...

9 days ago | 0

| accepted

How to find the index of the first absolute minimum entry of a matrix
A = [5,7,0.5,5;2,0.5,4,1;0.5,6,7,9]; [V,X] = min(A.',[],'all'); [C,R] = ind2sub(size(A),X)

9 days ago | 0

"I have created two .dat files using a same perl script, but on different machines." And they have created different files. "C...

9 days ago | 0

TUTORIAL: Comma-Separated Lists and How to Use Them
A common misunderstanding of comma-separated lists involves nested structures. The expectation is that dot-indexing at arbitrary...

10 days ago | 0

Evaluating a function with Matlab
"Can anyone help me figure out why I am getting an imaginary number in the following code:" Because you are taking the power of...

10 days ago | 0

| accepted

storing excel data in matrix using for loop
n = 4; A = zeros(n,20); F = 'filename.xyz'; for y = 1:n S = sprintf('sheetname_%d',y); A(y,:) = readmatrix(F, 'Shee...

12 days ago | 0

Create new matrices based on the number of unique values
Those three matrices are a red-herring. M = [4,7,2;2,4,7;2,2,4] [U,~,X] = unique(M(:)); S = accumarray(X,M(:)) [~,Y] = max(S...

14 days ago | 1

| accepted

sum a column in a matrix
F = @(t) sum(t{:,7}); V = cellfun(F,Tables)

14 days ago | 1

| accepted

How can I avoid using addpath to read files outside Matlab's search folder?
" Is it correct that before files can be read by Matlab, the folder where files are located have to be added to Matlab's search ...

15 days ago | 0

| accepted

How to use outerjoin for multiple files
fnm = compose("file%d.csv",1:5); tbl = readtable(fnm(1)); tbl.Properties.VariableNames = {'Key1','Var1'}; for k = 2:numel(fnm...

15 days ago | 1

| accepted

Counting outcomes of names
str = ["Sam";"Joe";"TPG, Sam, Joe";"TPG, Joe"] spl = regexp(str,',','split'); [uni,~,idx] = unique(strtrim([spl{:}])); cnt = ...

16 days ago | 1

Make function in function
syms x g = 5*x f = g+3

16 days ago | 0

extract a number within brackets from a cell of a table
txt = '(2.59836893721600e+01dB,0.00000000000000e+00°)' num = sscanf(txt,'(%f')

16 days ago | 0

I want to loop for files in workspace
"Let's say I have data1, data2,... and dataN in my workspace." Lets assume that you did not name them all by hand, but instead ...

16 days ago | 0

| accepted