Community Profile

photo

Stephen Cobeldick


5.349 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 to save a plot with the name of the file
Use the mfilename function: M = mfilename(); C = {'Fo','Mn','Ni'}; for k = 1:3 F = sprintf('%s%d_%s.jpg',M,k,C{k}) ...

etwa 11 Stunden ago | 0

Answered
how to generate permutations of N numbers in K positions
Download Loginatorist's powerful FEX submission combinator: https://www.mathworks.com/matlabcentral/fileexchange/24325-combinat...

etwa 13 Stunden ago | 0

Answered
How to create a multi-index vectors?
Start by downloading John D'Errico's excellent partitions function: https://www.mathworks.com/matlabcentral/fileexchange/12009-...

etwa 13 Stunden ago | 0

| accepted

Answered
Splitting a matrix based on certain values in the rows
No loop required: >> idx = cumsum(all(A==911,2)); >> row = 1:numel(idx); >> fun = @(r){A(r(2:end),:)}; >> C = accumarray(idx...

etwa 15 Stunden ago | 0

Answered
How to sort the results correctly in this "for" loop?
Simply download my FEX submission natsortfiles: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filena...

etwa 18 Stunden ago | 1

| accepted

Answered
How to fix this error in "for" loop?
You are trying to use the maximum value itself as an index, which is unlikely to work. You shoudl instead get the index on the m...

etwa 20 Stunden ago | 0

Answered
Experts of MATLAB, how did you learn? Any advice for beginner/intermediate users?
I reject the label "expert", but here is my two cents worth anyway: MATLAB Specific: MATLAB has a great feature that very few ...

ein Tag ago | 50

| accepted

Answered
Change colour order and restore it
"I want to change figure colour order" Figures do not have a ColorOrder property, only axes do. It is easy to change the axes'...

ein Tag ago | 0

Answered
how to choose the number in a random manner
C = randi(G)

2 Tage ago | 0

Answered
How Can I count the ascending runs in array ?
As KSSV wrote, you might find diff useful: >> y = y([1,1:end]) y = 1 1 1 0 0 1 1 1

2 Tage ago | 0

Answered
Vectorized Search of substrings in Cell Array
>> t = {'abcde','bcde','abc','ac'}; >> ~cellfun(@isempty,strfind(t,'bc')) ans = 1 1 1 0

2 Tage ago | 1

| accepted

Answered
To get the column number of max and min number
>> a = [1,5,3,7,4] a = 1 5 3 7 4 >> [~,mxi] = max(a) mxi = 4 >> [~,mni] = min(a) mni = 1

3 Tage ago | 1

| accepted

Answered
Little Bit Help Required Regarding Loop
"I just want to save all the values means every time when loop run it keep save the last results and save the new results in the...

3 Tage ago | 1

| accepted

Answered
Get one element from each row but not the same column
All six permutations of sums selecting one value from each row: >> N = 3; >> A = randi(9,N,N) A = 8 4 8 9 6 7...

3 Tage ago | 1

Answered
what does the L-shaped bracket mean?
Those brackets are actually the common way in mathematics to represent the floor function: https://www.mathsisfun.com/sets/func...

3 Tage ago | 2

Answered
Matrix element changing with loop
5 is a scalar. A scalar has size 1x1. On the second loop iteration a has size Nx2 (we don't know the actual size because you di...

3 Tage ago | 0

Answered
how do you check that a value input into your code is exactly 7 digits long before proceeding?
idNumber = '1234567'; assert(numel(idNumber)==7,'Wrong length ID number')

4 Tage ago | 0

Answered
How can I generate an array of binary data of this form?
It might not be the most beautiful algorithm in the world, but this works (on 64 bit MATLAB) for even N values up to at least N...

4 Tage ago | 1

| accepted

Answered
Conditional function creating with @ handle
Directly for this specific calculation: >> f = @(x,y) x + y*(1-2*((x*y)<=1)); >> f(1,2) ans = 3 >> f(2,1) ans = 3 It wor...

5 Tage ago | 1

| accepted

Answered
Passing data through fminsearch
You should definitely avoid global variables. For your situation the easiest way to parameterize a function is to use a simple ...

6 Tage ago | 0

Answered
Any suggestion on how to solve this problem using Matlab?
I know this is homework, but someone needs to show that it is a waste time writing loops, it is much better to write simple vect...

6 Tage ago | 0

Answered
Duplicate every element of a matrix to NxN elements
>> M = [1,2;3,4]; >> kron(M,[1,1;1,1]) ans = 1 1 2 2 1 1 2 2 3 3 4 4 3 3 4 4

6 Tage ago | 0

| accepted

Answered
accumarray does not return the correct sum
Your data: hdr = {'Date','ID','x','y','z','Profit'}; arr = {... '01-Jan-2019' 157350 0 1 100 0.470000000000000 '01-Jan-2019'...

7 Tage ago | 1

Answered
Strange behavior of the editor in the forum
Unfortunately the new editor does not work with Windows high-contrast mode, most of the toolbar buttons end up totally blank: ...

7 Tage ago | 0

Answered
where (what package) is the Matlab's wvd function?
Signal Processing Toolbox. You can easily find this out yourself using the online help, simply finding that page using your fav...

7 Tage ago | 0

Answered
Using cellfun() to set cell array of graphic objects 'Visible' Property to 'off'
You will need to define an anonymous function like this: cellfun(@(g)set(g,'Visible','off'),your_cell_array_of_handles) Note t...

7 Tage ago | 2

| accepted

Answered
Create function handle with several variables/arguments
Why not just vectorize the multiplication and summation?: fun = @(z) sum(cv(:).*z(:)); https://www.mathworks.com/help/matlab/m...

8 Tage ago | 2

| accepted

Answered
How to concentrate matrix 100 times?
Your approach is entirely in the wrong direction: using numbered variables is a sign that you are doing something wrong with you...

8 Tage ago | 0

| accepted

Answered
How to use the prctile (X,p,'all') function?
According to the MATLAB documentation the 'all' option was added in version R2018b: https://www.mathworks.com/help/stats/releas...

9 Tage ago | 1

| accepted

Answered
Using the matlab to achieve the a(k)+a(j) when k is not equal to j in every stage
a = [1,2,3,4]; for k = 1:4 b = 0; for j = 1:4 if j~=k b = b + a(k) + a(j); en...

9 Tage ago | 0

| accepted

Load more