Community Profile

photo

Stephen Cobeldick


Last seen: Today
6,613 total contributions since 2014

Suspensa Vix Via Fit

Stephen Cobeldick's Badges

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

View details...

Contributions in
View by

Answered
How to read line with multiple separate headers and tabs in between values
Importing the matrix data as numeric is much easier: opt = {'CollectOutput',true}; [fid,msg] = fopen('sample.txt','rt'); asse...

11 hours ago | 0

Answered
What is the best/right way to get a warndlg message/string?
>> x = warndlg(); >> h = findobj(x,'Type','Text'); >> get(h,'String') ans = 'This is the default warning string.'

12 hours ago | 1

Answered
saving variables programmatically using list of variable names
The simple solution is to use a comma-separated list: varNames = {'a','b','c'}; save('myMatFile',varNames{:}) % ...

12 hours ago | 1

| accepted

Answered
Separating and sorting a character string of magnetometer data (X,Y,Z,temperature) into separate arrays of doubles
>> str = 'X-123.3 Y30.3 Z500.4 t24.5'; >> tkn = regexpi(str,'([A-Z]+)(\S+)','tokens'); >> tkn = vertcat(tkn{:}) tkn = '...

12 hours ago | 0

| accepted

Answered
Found another way please don't answer
Simpler and more efficient: >> N = 17; % number of tosses >> V = randi(2,1,N) % 1=tails 2=heads V = 2 1 2 2 2 2...

19 hours ago | 0

Answered
why interp2 report "input grid is not a valid meshgrid" since input grid is generated by meshgrid?
"If anyone knows this issue..." Explanation: you swapped around the order of the variables: [Z,Y] = meshgrid(za,ya); % order: ...

23 hours ago | 1

Answered
Error using sscanf Invalid format.
The sscanf documentation explains its syntax as "A = sscanf(str,formatSpec) reads data from str, converts it according to the fo...

23 hours ago | 0

| accepted

Answered
Error using fread Invalid file identifier. Use fopen to generate a valid file identifier.
The problem is that your code only uses the filename, but you need to also provide the filepath (otherwise how does MATLAB know ...

1 day ago | 0

| accepted

Answered
MATLAB Colormap doesn't work past 12 colors
" when there are 14 colors in the map, even if the extra two are unused..." That depends on what you are doing. Depending on t...

1 day ago | 0

Answered
Matching unequal cell arrays
Using tables: >> TA = cell2table(A(:)) TA = Var1 ____ 124 252 252 1252 225 225 ...

1 day ago | 0

Answered
Assign a number of random elements to different variables?
Using one cell array is much better than having lots of separate variables, so that is what this answer does. >> v = randperm(4...

1 day ago | 1

Answered
Nested tables with duplicate sub-column names?
The link you gave is unrelated to nested tables: the goal there was to (in some way) merge multiple tables into one table. It i...

2 days ago | 0

| accepted

Answered
Average of multiple cell arrays
Assuming that each cell contains a 1x22051 vector (i.e. they are all the same size): avg_ydft = mean(cat(3,ydft{:}),3) https:/...

2 days ago | 0

| accepted

Answered
How to sum the second poation data in an array (50000x2) with the same value in the first position
Method one: accumarray: >> [U,~,G] = uniquetol(A(:,1)); >> S = accumarray(G(:),A(:,2)); >> M = [U,S] M = 2.79314 0.141...

3 days ago | 0

| accepted

Answered
read csv. convert char-array to matrix
Because MATLAB does not handle UCS-2 file I first converted your file to UTF-8 (attached). This imports all of the main matrix ...

3 days ago | 0

Answered
Help with printing output
Instead of adding spaces manually you can set the fieldwidth: hours = [13,22,41]; x = [74.52,30.02,22.68]; y = [77.40,36.30,2...

4 days ago | 0

| accepted

Answered
Access all k-th elements of a n-dimensional array, where the k indexes are defined in a (n-1)-dimensional array.
>> S = size(A); >> [R,C,~] = ndgrid(1:S(1),1:S(2),1); >> X = sub2ind(S,R,C,idx); >> B = A(X) B = 1 11 3 13 ...

4 days ago | 0

| accepted

Answered
For loop using bin2dec conversion
This is MATLAB, you don't need a for loop! Method one: mtimes: >> V = [1,1,0,1,0,0,1,0]; >> N = 2; >> X = pow2(N-1:-1:0)*res...

7 days ago | 0

| accepted

Answered
Matrix Generation from Other Matrices
F = @(p)C*A^p*B; M = arrayfun(F,0:n-1,'uni',0); M = cumsum(cat(3,M{:}),3); M = reshape(permute(M,[1,3,2]),[],b); Tested: >>...

7 days ago | 0

| accepted

Answered
Replacing NaN's in column of a Matrix
Where M is your matrix: X = isnan(M(:,2)); M(X,2) = 250;

7 days ago | 1

| accepted

Answered
For loop goes longer than expected.
"Can you help me what is the cause for this behaviour?" Because that is the indexing that you used. You defined the loop itera...

8 days ago | 0

| accepted

Answered
Average of the nine surrounding cells
Use conv2 to calculate the averages, e.g.: out = matrix2.*conv2(matrix1,ones(3,3),'same')/9;

8 days ago | 1

| accepted

Answered
How to separate an array into 3
>> A = [11,22,33,44,55,66,77,88,99]; >> B = A(1:2:end-1) B = 11 33 55 77 >> C = A(2:2:end-1) C = 22 44 66 88...

8 days ago | 1

Answered
modify the matrix, rearrangement of elements
>> a = [2,4,7,11;7,9,5,54;2,5,7,9;12,41,45,21] a = 2 4 7 11 7 9 5 54 2 5 7 ...

9 days ago | 1

Answered
How can I create a new cell array from an existing one?
Country = strrep(Country,'"','')

9 days ago | 0

| accepted

Answered
Numerical error representing data in Format Long
"I have had a surprise making with this simple multiplication:" Nothing in that result is surprising. "The result must be 8.2e...

9 days ago | 1

| accepted

Answered
Is it possible to determine within a function the location of that function?
https://www.mathworks.com/help/matlab/ref/mfilename.html p = mfilename('fullpath') [p,n] = fileparts(p)

10 days ago | 0

Answered
How to list files in the directory
https://www.mathworks.com/help/matlab/ref/dir.html D = 'absolute/relative path to where the files are saved'; S = dir(fullfile...

10 days ago | 0

| accepted

Answered
Concatenate same fields in multiple structures in a loop using field names
Because all of the structures contain the same fieldnames they should be stored as one non-scalar structure: https://www.mathwo...

10 days ago | 0

| accepted

Answered
How to generate all combinations of N struct vectors.
It is much simpler when those structures are stored in one cell array, e.g.: C{1}(1).a = 5; C{1}(2).a = 9; C{2}(1).b = 2; C{...

10 days ago | 0

Load more