Community Profile

photo

Stephen Cobeldick


5,227 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
I am having a error using fprintf
You should always return the second output of fopen and check the f_id value: [f_id,msg] = fopen(txt_name,'wt'); assert(f_id>=...

약 1시간 ago | 0

| accepted

Answered
folder split into parts
In two lines: movefile('Prostatex0000_*.nii','subdir0') movefile('Prostatex0001_*.nii','subdir1')

약 2시간 ago | 0

Answered
How to store the result of a loop in a cell?
Your code is only iterating once, because for i = 1:44 ^^ you forgot this. PS: I would recomend using ii or k as the ...

약 4시간 ago | 0

| accepted

Answered
Flipping specific segment of string rather than the whole string
regexprep(str,'\w+','${fliplr($0)}')

약 4시간 ago | 2

Answered
I am getting an error as "Operands to the || and && operators must be convertible to logical scalar values. Error in xd (line 8) if (t>=t1)&&(t<t2)".
Learn to use logical indexing https://www.mathworks.com/help/matlab/getting-started-with-matlab.html Logical indexing is a ver...

약 8시간 ago | 0

Answered
Reading a number from text file
>> str = fileread('MASS.txt'); >> tmp = regexp(str,'(?<=X\s+)\d+\.?\d*E[-+]\d+','match','once'); >> str2double(tmp) ans = 3....

약 9시간 ago | 0

| accepted

Answered
choose row cell of matrix
A general solution in one line: C = cellfun(@(r)A(r,:),B,'uni',0)

약 10시간 ago | 0

| accepted

Answered
How to plot an empty 2-D cartesian grid on its own ?
>> axes() >> xlim([200,455]) >> ylim([50,305]) >> grid on >> grid minor Or alternatively in one axes call: axes('XLim',[20...

약 11시간 ago | 0

Answered
How can I convert matrix in cell array to same size cell array within the original array without for loop?
Where C is your 4x1 cell array: D = cellfun(@num2cell,C,'uni',0)

1일 ago | 0

| accepted

Answered
how to flip a general square matrix ( it could have even or odd number of rows/cols ) from it's center in matlab ?
>> M = [1,2,3,4,5;2,6,7,9,10;3,7,11,12,13;4,9,12,16,20;8,10,13,20,25] M = 1 2 3 4 5 2 6 7 9 10...

1일 ago | 0

| accepted

Answered
how to convert to a cell array from a single precision array
Simpler to use num2cell: >> a = [1.1,1.2;2.1,2.2;3.1,3.2] a = 1.1000 1.2000 2.1000 2.2000 3.1000 3.2000 >> ...

1일 ago | 2

Answered
Why do I have to type '^' plus the next character two times?
This behavior is perfectly normal. It depends solely on your language and keyboard settings. Some keyboards use the ^ key (and ...

2일 ago | 2

| accepted

Answered
How to create and load a custom colormap?
Assuming that mymap is a variable in the workspace: colormap(gca,mymap);

2일 ago | 1

| accepted

Answered
Cell array: select only 1x3 double cells
Where C is your cell array: X = cellfun('length',C)==3; out = C(X) https://www.mathworks.com/help/matlab/matlab_prog/access-d...

2일 ago | 0

| accepted

Answered
find array inside a cell
Simpler in one line: >> A = {[1,2,4],[2,3,7],[2,5],[4,5,6]}; >> B = [1;2;3;6;8]; >> C = cellfun(@(m)intersect(m,B),A,'uni',0)...

3일 ago | 0

| accepted

Answered
What next in the code
Your function definitions are not correct. Instead of this invented syntax: Function 1 [W] = Naturalfreq(k,m) ... your code ...

3일 ago | 0

Answered
Is there an efficient way to create a matrix with all permutations of inserting one array into another?
Perhaps something like this: >> A = [1,5,6]; % remaining >> B = [4,3,2]; % reversed >> N = numel(A); >> M = toeplitz([B,zero...

3일 ago | 1

| accepted

Answered
Nested Indexing in a Single Line command
>> C = {'George: A5 == BB'; 'Anna: C3 == DD'; 'Smith: E2 == FFF'; 'Ken: G8 == HHHH'}; >> D = regexp(C,'^(\w+):\s*(\w+)\s*==\s*(...

3일 ago | 0

Answered
Calculate different rowss in a matrix
B = [A(1:30,:)*10;... A(31:180,:)*5;... A(181:300,:)*10]

3일 ago | 0

Answered
Saving file issue while trying to add variables
You are saving to different files: save(mysave,...) save(filename,...)

3일 ago | 0

| accepted

Answered
How can i find helper functions in Matlab?
At the bottom of the page, in a section entitled "Appendix", you will find the links to those functions:

3일 ago | 0

Answered
Add new elements into cell array inside a loop
This will store the data each iteration of both loops (but I did not change the logical conditions): N = size(TestData,1); % mu...

3일 ago | 0

Answered
Count number of repeated element before next different number in array?
>> D = diff([0,A==1,0]); >> find(D<0)-find(D>0) ans = 3 1 2 4

3일 ago | 0

| accepted

Answered
Subscript indices must either be real positive integers or logicals.
Better to iterate over integer indices rather than fractional values: V = 1:0.1:20; N = numel(V); M = nan(N,3); for k = 1:N ...

3일 ago | 0

| accepted

Answered
i have one variable which has value in an array and i want to make the power of all the value of array by another variable but getting value zero.any possible solution?
"any possible solution?" Solution to what, exactly? You calculate this (the loop is not required): >> alpha.^lambda ans = ...

3일 ago | 2

Answered
Horizontally concatinating the fields of a structure with different dimensions.
The different number of rows does not prevent them from being concatenated vertically: >> S.f1 = [0,1;2,3;4,5]; >> S.f2 = [6,7...

3일 ago | 0

| accepted

Answered
How to change string name?
The solution is to simply use indexing. For example, you could put all of your imported data into one cell array. You did not gi...

4일 ago | 2

| accepted

Answered
How to extract locations from strings of addresses?
Using one simple regular expression: >> C = {... 'Sustainable Industrial Systems, School of Chemical Engineering and Analyti...

4일 ago | 1

| accepted

Answered
I need some help with understanding the '2' close to the second d
>> fprintf ('The square of %d is %2d\n', [a;asq]) The square of 1 is 1 The square of 2 is 4 The square of 3 is 9 The squa...

4일 ago | 0

Answered
How to get a value from a matrix?
You should never compare for exact equivalence of floating point numbers, read this to know why: https://www.mathworks.com/matl...

5일 ago | 0

| accepted

Load more