Community Profile

photo

Stephen Cobeldick


5,594 total contributions since 2014

Suspensa Vix Via Fit

Stephen Cobeldick's Badges

  • Master
  • 36 Month Streak
  • Thankful Level 4
  • Revival Level 2
  • Knowledgeable Level 4
  • First Answer

View details...

Contributions in
View by

Answered
How can I create all possible random combinations of word pairs without having the same values (for example, house - house)?
Pick random rows from X to get the random pairs: >> Tile = {'house', 'core', 'word', 'ask', 'question', 'horse', 'phone', 'eyes...

1 hour ago | 0

| accepted

Answered
to print following pattern
Three lines, no loop, and only basic numeric operations used: >> X = 1:9; >> Y = floor((137174210/1111111111)*10.^X); >> fpri...

2 hours ago | 1

Answered
automatically filling a matrix
Just use blkdiag and a comma separated list: >> n = 5; >> j = 6; >> C = {-ones(n,1)}; >> M = blkdiag(C{ones(1,j)}) M = -...

6 hours ago | 0

| accepted

Answered
combining different csv files from a folder into one matrix
"Is theremaybe a way to list the filenames in the same order, then add them afterwards as the top row to the table?" You could ...

8 hours ago | 0

| accepted

Answered
Inserting more rows between already existing rows of a structure
"but I am not sure how to tansfere that onto a structure. " In exactly the same way. All MATLAB arrays use the same indexing co...

20 hours ago | 0

Answered
How to use eval and disable the edit box or drop down?
Do NOT use eval for trivial code like this! Much better is to read the documentation on dynamic fieldnames: https://www.mathwo...

20 hours ago | 1

| accepted

Answered
How do I extract images from a docx (word) file?
All OpenOffice XML formats (e.g. .docx, .xlsx, etc.) constitute XML files and supporting files zipped together into one file. Yo...

21 hours ago | 0

Answered
Generate combinations of Cells that contain text
Simple and efficient with ndgrid and strcat: >> [Cx,Bx,Ax] = ndgrid(1:numel(C),1:numel(B),1:numel(A)); >> D = strcat(A(Ax(:)),...

1 day ago | 0

Answered
Find Borders and their Indices
Simple and efficient using diff and find: >> D = diff([false,A==0,false]); >> B = find(D>0) % begin of run of zeros B = 1...

1 day ago | 1

| accepted

Answered
subtracting a number from string
The most efficient solution by far (and simple too!): >> str = 'subject1_EO'; >> val = sscanf(str,'subject%f') val = 1

1 day ago | 0

Answered
Convert cell to duration array
"Is there an elegant equivalent to "cell2mat" when cell content is "duration"?" Yes, this is really easy with a comma-separated...

1 day ago | 1

| accepted

Answered
i have a problem with use of natsortfiles function and divide my images
It is not clear what you expect this line structtt = cat(1,cellFileNames{:}); to do, but in actual fact it will vertically con...

1 day ago | 1

| accepted

Answered
how can i express the following question in matlab about save command?
Use uiputfile for a more professional user interface, e.g.: [F,P,X] = uiputfile({'*.jpg';'*.png'}); imwrite(A,fullfile(P,F))

1 day ago | 0

Answered
how to loop through subfolders and apply a particular function
A simple function which correctly handles special characters in the pattern and actually calls the nested function recursively: ...

5 days ago | 0

Answered
replacing uiget with pathname and filename
You use dir without any specific name+wildcards, so it will return all contents of that folder (i.e. files and folders). You the...

5 days ago | 1

| accepted

Answered
finding the right values for a vector
Use mrdivide: >> V = (1:15).'; >> a = pi; >> M = a/V M = 0.0025335 0.0050671 0.0076006 0.0101342 0.0126677 0.0...

5 days ago | 1

Answered
get the value of element from matrix
Simply use ismember and basic MATLAB indexing: >> [X,Y] = ismember(B,A(:,1:2),'rows'); >> Z = A(Y(X),:) Z = 9 9 ...

5 days ago | 0

| accepted

Answered
Finding corresponding values in double arrays in structure fields
Note that these methods assume that there is exactly one match per row. If this is not the case, then there is no way to disting...

6 days ago | 2

| accepted

Answered
filling a matrix with a loop
"Does anyone know how to do this?" This is simple and efficient with toeplitz: >> C = [1,zeros(1,399)]; >> R = [1,1,0,1,zeros...

8 days ago | 3

| accepted

Answered
anyway to translate this command using 'cellfun'
Note that it is simpler to use strfind: >> C = strfind(test,'_'); >> C{:} ans = 2 ans = 2

8 days ago | 0

| accepted

Answered
Create a matrix with random integers between 1 and 9
>> reshape(randperm(9),3,3) ans = 6 8 2 3 5 4 7 1 9

8 days ago | 0

| accepted

Answered
Meaning imaginary result of asin(x) function of MATLAB
"'My question is how can we interpret this imaginary number? Does it have any meaning? Yes, it has a meaning. Why does MATLAB ...

9 days ago | 1

Answered
What `gcbf` stands for?
gcbf get callback figure gcbo get callback object These are not necessarily the current ones.

9 days ago | 1

| accepted

Answered
Sorting columns of cell Array
Either download my FEX submission natsort: https://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-orde...

9 days ago | 1

| accepted

Answered
the problem of using 'case'
Your first (inadvisable, numerically fragile, should-be-avoided) concept works for me: for omega = 0.1:0.1:2; switch omega ...

9 days ago | 1

| accepted

Answered
Search a matrix combined with logical indexing
>> A = [3,10,2,5;2,14,5,3] A = 3 10 2 5 2 14 5 3 >> N = 10; >> B = A.*(cumsum(A>N,2)>0) B = 0...

11 days ago | 0

| accepted

Answered
Storing multiple value in array without overriding.
"How to avoid that?" Simply by changing the Excel worksheet name on each iteration of the outer loop, e.g.: ... for z=1:nfile...

11 days ago | 0

| accepted

Answered
How to create a for loop through a directory for only certain folders in the directory
An efficient MATLAB solution: P = 'absolute/relative path to the parent directory Sample'; S = dir(fullfile(P,'sub*')); F = {...

11 days ago | 0

Answered
How can I make an array of structs , each struct have a unique index?
"How can I make an array of structs , each struct have a unique index?" Easily: https://www.mathworks.com/help/matlab/matlab_pr...

12 days ago | 0

| accepted

Answered
Regular Expressions using regexp
Matching only integer numbers after 'UZK' or 'T_' (it is unclear in your question if the underscore is permitted or not, but the...

12 days ago | 1

| accepted

Load more