Community Profile

photo

Stephen Cobeldick


Last seen: Today
7.112 total contributions since 2014

Suspensa Vix Via Fit

Stephen Cobeldick's Badges

  • 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 4
  • Revival Level 2
  • Knowledgeable Level 4
  • First Answer

View details...

Contributions in
View by

Answered
Convert cell array to vector
S = load('timestamps.mat'); T = vertcat(S.ans{:}) M = seconds(mean(diff(duration(T,'InputFormat','hh:mm:ss.SSS'))))

43 Minuten ago | 0

Answered
Create a Slanted Linspace Matrix
hankel(1:4,4:7)

etwa 4 Stunden ago | 0

Answered
Maximum number of repeated values over an array
a = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9]; x = cumsum([true;diff(...

etwa 5 Stunden ago | 1

| accepted

Answered
How to compare greek letters if they are same
Rather than building maps by hand, I would get Python to do the heavy lifting, e.g.: baz = @(v)char(v(1)); % only need the firs...

etwa 7 Stunden ago | 0

Answered
How to convert time stamp 11:21:17.155 into seconds in MATLAB??
The most efficient solution: a = '11:21:17.155'; b = [60*60,60,1]*sscanf(a,'%f:')

ein Tag ago | 0

Answered
Is it possible to make a loop where the the result is separate from the loop and have the result respectively with the input?
Use a cell array to store the data: p = 'Quantity of product you have bought today: '; n = str2double(input(p,'s')); c = cell...

ein Tag ago | 0

| accepted

Answered
"If function" can't distinguish i ~= 1.6.
"This weird thing only happens when i=1.6." Nothing weird happens: you generate binary floating point numbers using two differe...

2 Tage ago | 1

| accepted

Answered
replacing loop with cell of index values
s = 1:100; c{1} = 1; c{2} = 1:5; c{3} = 2:2:10; out = cellfun(@(x)s(x),c,'uni',0); out{:} A well-written (i.e. correctly p...

4 Tage ago | 1

| accepted

Answered
Colors in Matlab as a vriable
Perhaps something like this: M = [1,0,0;... red 1,1,0;... yellow 0,1,0]; % green X = strcmpi(Auto.Farbe,{'red','ye...

8 Tage ago | 0

Answered
Opening multiple .csv files using readtable
% opts is unchanged D = 'C:\Users\krist\OneDrive\Documents\MATLAB'; S = dir(fullfile(D,'*.csv')); for k = 1:numel(S) F =...

8 Tage ago | 1

| accepted

Answered
How to create matrix with other matrixes by joining them?
a = [1 2 3]; b = [4 5 6]; c = [7 8 9]; d = [10 11 12]; res = reshape([a;c;b;d],2,[])

9 Tage ago | 2

| accepted

Answered
saving the data in a variable
"...how to change the name of the file when matlab saves it" That is easy: https://www.mathworks.com/help/matlab/import_export...

9 Tage ago | 0

Answered
How to iterate over cell array, creating only unique combinations of cells
data = {1,2;3,4}; n = numel(data); m = nchoosek(1:n,2) % each row is one combination pair. out = data(m) % output [idr,idc] ...

9 Tage ago | 0

| accepted

Answered
how to arrange data into array
Without an intermediate sparse array: R = [1;2;3;4]; C = [10;11;13;15]; V = [1e-5;5e-5;10e-5;15e-5]; % S = max([R,C],[],1);...

10 Tage ago | 0

Answered
How to count the number of times that values changes?
A = [1;1;1;2;1;3;3;1;1] B = [NaN;cumsum(diff(A)~=0)]

11 Tage ago | 3

| accepted

Answered
Getting rid of loops
Logical indexing is much simpler than using loops: idx = A<1 & A>0; A(idx) = B(idx); A(A<C) = NaN; idy = B>100 | B<0; ...

11 Tage ago | 0

| accepted

Answered
How to conditionally merge rows in a table
lat = [45.67, 45.67, 56.89, 78.61]'; lon = [-66.45, -66.45, -65, -67]'; id = [202, 202, 201, 200]'; key = {'A', 'B', 'C', 'C'...

12 Tage ago | 0

| accepted

Answered
Increment components of vector till a desired limit
for k = 6:100 % or 105 maybe... you can check this. v = reshape(hankel(1:5,5:k),1,[]) end

12 Tage ago | 2

Answered
Expected one output from a curly brace or dot indexing expression but there were 2 results
For your code to work the index tn4 must be scalar, but the error message tells us that it is not. Compare: S(1).blah = 1:3; ...

12 Tage ago | 0

| accepted

Answered
behaviour of nargout for anonymous functions
You get two different answers because you are testing two different functions: the function handle to addOne an anonymous func...

12 Tage ago | 0

| accepted

Answered
Combining cell arrays with empty doubles
% slightly more complex example data: a = {[],1;[],[]}; b = {[],[];2,[]}; c = {[],[];[],NaN}; % tmp = cat(3,a,b,c); [~,idp...

12 Tage ago | 2

| accepted

Answered
How to properly extract dataset and load in new file? Keep getting error.
There is no data field because you saved the array using the name Xs. So you need to use the field Xs (and get rid of the superf...

12 Tage ago | 0

| accepted

Answered
How do I insert data into new format based on row positions?
data = [8; 7; 1; 5]; datarowpositions = [0; 0; 0; 4; 0; 1; 0; 2; 0; 0; 3; 0]; desired = datarowpositions; desired(datarowposi...

13 Tage ago | 0

| accepted

Answered
naming using a string function
The MATLAB approach: N = numel(files); C = cell(1,N); for k = 1:N F = fullfile(files(k).folder,files(k).name); C{k}...

13 Tage ago | 0

Answered
how to iterate?
I don't see why any iterations are required, vectorized code will do this quite easily: A = [-120449852, -107496428]; B = [-10...

13 Tage ago | 0

| accepted

Answered
Repeat a string with a delimiter
A = 'abc'; B = join(repmat({A},1,3),', '); B = B{1} C = join(repmat(string(A),1,3),', ') % string output! D = sprintf('%1$s,...

13 Tage ago | 0

Answered
Remove parenthesis and the contents inside from a string
A = 'abc (ABC)'; B = regexp(A,'^\w+','once','match')

13 Tage ago | 0

| accepted

Answered
Programmatically change function input
Using a character vector is entirely the wrong approach. The correct approach is to use a comma-separated list: tt = synchroniz...

14 Tage ago | 0

| accepted

Answered
how can I display 3 row vectors as column vectors in front of eachother using fprintf?
a = [1,2,3]; b = [11,22,33]; c = [111,222,333]; fprintf('%d %d %d\n',[a;b;c])

14 Tage ago | 0

| accepted

Answered
Find rows in cell for each array between two values and create new cell with the values you just found
Using linear indexing to access the cell arrays only requires one loop: n_new = cell(size(n)); for k = 1:numel(n) idx = f...

15 Tage ago | 0

| accepted

Load more