
Stephen23
Suspensa Vix Via Fit
Statistics
RANK
5
of 257,934
REPUTATION
30,274
CONTRIBUTIONS
4 Questions
7,957 Answers
ANSWER ACCEPTANCE
75.0%
VOTES RECEIVED
4,943
RANK
123 of 17,771
REPUTATION
8,923
AVERAGE RATING
4.90
CONTRIBUTIONS
22 Files
DOWNLOADS
848
ALL TIME DOWNLOADS
69253
RANK
of 110,154
CONTRIBUTIONS
0 Problems
0 Solutions
SCORE
0
NUMBER OF BADGES
0
CONTRIBUTIONS
0 Posts
CONTRIBUTIONS
0 Public Channels
AVERAGE RATING
CONTRIBUTIONS
0 Highlights
AVERAGE NO. OF LIKES
Content Feed
Calculate mean value of every element of a .mat file
S = load(..); C = fieldnames(S); for k = numel(C) M = S.(C{k}); V = mean(M,1); S(k).mean = V; end A = vertcat...
1 day 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)
1 day 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)
2 days ago | 0
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...
3 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)
3 days ago | 0
About importdata(filename) function in Matlab
"I have created two .dat files using a same perl script, but on different machines." And they have created different files. "C...
3 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...
4 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...
4 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...
6 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...
8 days ago | 1
| accepted
sum a column in a matrix
F = @(t) sum(t{:,7}); V = cellfun(F,Tables)
8 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 ...
9 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...
9 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 = ...
10 days ago | 1
extract a number within brackets from a cell of a table
txt = '(2.59836893721600e+01dB,0.00000000000000e+00°)' num = sscanf(txt,'(%f')
10 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 ...
10 days ago | 0
| accepted
Extracting specific data from table
idx = startsWith(valores_sensores.ID,'ILM_'); % or CONTAINS SensorILM = valores_sensores(idx,:)
10 days ago | 0
| accepted
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)
13 days ago | 0
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...
13 days ago | 0
| accepted
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...
15 days ago | 1
| accepted
Extracting 2 Far right characters
tt = {'United Kingdom TR';'United Kingdom SR';'United Kingdom WR';'Worldwide TC'}; pe = regexp(tt,'\w\w$','match','once')
16 days ago | 0
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. ...
16 days ago | 1
| accepted
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 ...
16 days ago | 0
| accepted
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 ...
17 days ago | 0
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...
18 days ago | 1
| accepted
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...
18 days ago | 1
| accepted
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) ...
18 days ago | 0
| accepted
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)
18 days ago | 2
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...
18 days ago | 1