Community Profile

photo

Stephen23


Active since 2014

Suspensa Vix Via Fit

Professional Interests:

Statistics

All
  • Most Accepted 2021
  • Grand Master
  • Personal Best Downloads Level 4
  • Editor's Pick
  • First Review
  • 5-Star Galaxy Level 5
  • GitHub Submissions Level 3
  • First Submission
  • 36 Month Streak
  • Thankful Level 5
  • Revival Level 2
  • Knowledgeable Level 5

View badges

Content Feed

View by

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

1 jour ago | 0

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

3 jours ago | 1

| accepted

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

4 jours ago | 1

| accepted

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

4 jours ago | 0

| accepted

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

4 jours ago | 1

| accepted

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

5 jours ago | 1

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

5 jours ago | 0

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

5 jours ago | 0

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

5 jours ago | 0

| accepted

Answered
Extracting specific data from table
idx = startsWith(valores_sensores.ID,'ILM_'); % or CONTAINS SensorILM = valores_sensores(idx,:)

5 jours ago | 0

| accepted

Answered
Concatenating matrix with specific cell in cell aray
C = {'hello',[1,2,5];'world',[3,5]} V = [4,5]; F = @(a)union(V,a); C(:,2) = cellfun(F,C(:,2),'uni',0)

8 jours ago | 0

Answered
How can I create a 2-term, 1-by-1 string using sprintf?
Here is a way to import those badly-named variables, assuming exactly one variable per MAT file: N = 17; C = cell(1,N); for k...

8 jours ago | 0

| accepted

Answered
Find exact string match in a cell of strings
C = {'This is XYZ1','This is XYZ11', 'This is XYZ1111','This is XYZ1.0'}; str = 'XYZ1'; rgx = sprintf('%s(?=$|\\s)',str); reg...

10 jours ago | 1

| accepted

Answered
Extracting 2 Far right characters
tt = {'United Kingdom TR';'United Kingdom SR';'United Kingdom WR';'Worldwide TC'}; pe = regexp(tt,'\w\w$','match','once')

11 jours ago | 0

Answered
Dot indexing is not supported for variables of this type. - trying to create a function to upload files matrices
I am guessing that you have very badly-designed data, where the variable in the MAT file uses the same name as the file itself. ...

12 jours ago | 1

| accepted

Answered
How to remove date and time columns after merging as date_time?
You can use REMOVEVARS: https://www.mathworks.com/help/matlab/ref/table.removevars.html Your code would be clearer if you use ...

12 jours ago | 0

| accepted

Answered
Sort a variables in structure
Rather than forcing pseudo-indices into fieldnames, why not use an array with indexing (e.g. a cell array) ? Here are two ways ...

12 jours ago | 0

Answered
Is there a good reason for choosing assert() over an if condition with an error?
"Is easier reading/fewer lines the only goal?" Why call two operators when you can call just one? It certainly can make the in...

13 jours ago | 1

| accepted

Answered
How to stop data being overwritten in for loop?
Use a structure array, which allows you different numbers of rooms on each storey. A simple example: NmS = 5; % number of store...

13 jours ago | 1

| accepted

Answered
Repeated elements in an array
A = [3 7 25 27 30 31 32 34 35 36]; B = [2 4 2 2 2 0 3 2 3 2]; Either define new variables: X = [true,diff(B)~=0]; C = A(X) ...

13 jours ago | 0

| accepted

Answered
convert current date and time to char
Avoid deprecated DATESTR and DATENUM. one = datetime('now','Format','yyyy-MM-dd''T''HH:mm:ss''Z''') two = one - hours(6)

13 jours ago | 2

Answered
Bad time format, import to datetime
"Bad time format" Good time format: it looks like a completely standard ISO 8601 timestamp https://en.wikipedia.org/wiki/ISO_8...

13 jours ago | 1

Answered
Choose specific values from dataset
txt = fileread('demodata1.txt'); rgx = '^\s+\d+\s+(\S+)\s+(\S+)'; tkn = regexp(txt,rgx,'tokens','lineanchors'); mat = str2dou...

13 jours ago | 1

| accepted

Answered
How do you build multiple cell arrays from the columns of an array?
M = randi(9,3,5) C = num2cell(M,1)

13 jours ago | 0

| accepted

Answered
Extract data from sequentially named tables
"So after loading the files, I am left with tables I cannot call, because they are named sequentially..." Actually there is a r...

14 jours ago | 1

Answered
How to import data from a .txt file with semicolons
Because you did not upload a sample file I had to create my own (attached). format short G mat = readmatrix('test.txt', 'Delim...

14 jours ago | 0

Answered
Different "kind" of variable
typ = ["oats","milk","water"] mat = [66,12,0;10,8,0;7,8,0] inp = ["milk","oats"]; qty = [2,0.5]; [~,idx] = ismember(inp,t...

14 jours ago | 0

Answered
How to flip an array without using the flip command ?
F = [-0.5,4.5,-2.0,3.6,8.5,7.3,2.5,1.2,6.5] P = F(end:-1:1)

14 jours ago | 0

| accepted

Answered
Problem with ploting exp function
"I think there is a problem with .*exp(x-y)" I doubt that. Did you look at the domains and ranges that you are plotting? Your ...

14 jours ago | 1

| accepted

Answered
How to SUMIF similar to Excel
"Not sure where this is going wrong." Reinventing the wheel by writing lots of loops, and ignoring the inbuilt tools. dt = dat...

14 jours ago | 0

Load more