Community Profile

photo

Stephen Cobeldick


5.503 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
Help with nested structure
This would be much easier if you had designed your data better. In particular, rather than using nested structures (which are r...

ein Tag ago | 0

Answered
While loop with for loop problem
Perhaps you meant something like this: D = [3 0 0; 0 2 0; 0 0 1]; b = [0; 1; 0]; L = [0 0 0; 1 0 0; 0 1 0]; U = [0 1 0; 0 0 ...

ein Tag ago | 0

Answered
Opening mat files with uiopen and copying data to array
It seems that whoever created those .mat files unfortunately named each structure with the same name as the filename, which just...

3 Tage ago | 0

| accepted

Answered
TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)
Slow The MATLAB documentation Alternatives to the eval Function explains that code that uses eval is slower because "MATLAB® co...

3 Tage ago | 7

Answered
How do I extract the same field from diferent struct files with names like AAA_1, AAA_2... AAA_n?
I suspect that ScanImage is badly written and saves variables (e.g. structures) with a different name in each .mat file. This ma...

3 Tage ago | 1

| accepted

Answered
Average of several (different, across) structures
Fake data in scalar structures: S1 = struct('A',randi(99,4,3,2),'B',randi(99,4,3,2)); S2 = struct('A',randi(99,4,3,2),'B',rand...

3 Tage ago | 0

Answered
Keeping record of Number of concatenated files
Inside your loop: N = ... the total number of files. C = cell(1,N) for k = 1:N M = ... import the matrix here. M(:,...

3 Tage ago | 0

Answered
Adding certain 'parts' of two matrices
B(2:3,2:3) = A

3 Tage ago | 0

| accepted

Answered
How to find out whether there is a repetitive element in the columns of a matrix?
"I just want to know whether there is or not." >> any(diff(sort(a,1),1)==0,1) ans = 1 1 0

4 Tage ago | 2

Answered
TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)
Alternative: save the Fields of a Scalar Structure The save command has an option for saving the fields of a scalar structure a...

4 Tage ago | 0

Answered
TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)
Alternative: load into a Structure, not into the Workspace In almost all cases where data is imported programmatically (i.e. no...

4 Tage ago | 5

Question


TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)
Sometimes beginners (and some self-taught professors) think it would be a good idea to dynamically create or access variable nam...

4 Tage ago | 18 answers | 30

18

answers

Answered
Finding arrays above threshold value
Fake data: AT(1).AX = rand(1,370); AT(2).AX = rand(1,1007); AT(3).AX = rand(1,3957); AT(4).AX = rand(1,6309); AT(5).AX = ra...

4 Tage ago | 1

| accepted

Answered
How to Convert a column with Char in Cell matrice to Number?
You almost got it right, you just need to split the numeric array into a cell array so that it can be allocated back to the cell...

5 Tage ago | 0

Answered
Could anyone help me how to solve the issue.
Using very basic MATLAB indexing: A = {[1,2],[3,4],[7,5,6]}; N = numel(A); Z = nan(1,N); for k = 1:N Z(k) ... your code...

5 Tage ago | 0

| accepted

Answered
Create a 20x24 matrix with each individual column with random integers without duplicate
You do not need a loop, here is a much simpler solution in just one line: >> [~,M] = sort(rand(20,24),1) M = 16 20 17 ...

5 Tage ago | 0

Answered
How to dissect a file path and keep extension Matlab
Do NOT use path as a variable name! This shadows the important inbuilt path function. To get the file extension use fileparts: ...

5 Tage ago | 1

| accepted

Answered
Why does the text file does not show me lines printed on next lines even when i used '\n' while printing the data in Matlab?
You should fopen the file in TEXT mode: fid = fopen(....'wt') % ^ TEXT mode! Or alternatively stop using retr...

5 Tage ago | 0

| accepted

Answered
How to get the value of exponential power?
Just use log10: >> floor(log10(a)) ans = -12 -13 The correct answer is [-12,-13], not [12,13] (because these are the powe...

6 Tage ago | 1

| accepted

Answered
Write to text file
You fopen-ed the file in read mode and not write mode (because the default mode is read mode and you did not specify any other m...

6 Tage ago | 1

| accepted

Answered
Matrix with full combinations of vectors'/matrices' elements
>> A = [1;2;3]; % Column vector! >> B = [4,5;6,7]; >> C = [8,9;10,11]; >> D = [12;13]; % Column vector! >> An = size(A,1); ...

7 Tage ago | 0

Answered
Making a array that gives me this kind of data...?
>> xp=5; >> x1=1.5; >> depth=2.3; >> Xv = -xp:0.1:xp; >> Yv = min(0,depth*abs(Xv)/x1 - depth); >> plot(Xv,Yv,'-*')

7 Tage ago | 1

| accepted

Answered
Sum Numbers Excluding Zeros
Simpler solution using accumarray: >> x = [0,0,0,1,0,2,2,3,4,0,0,0,0,7,8,2,2,0,3,0]; >> y = cumsum(x==0 | [true,x(1:end-1)==0]...

8 Tage ago | 1

Answered
How to compare each element of an array with the rest of the elements for several rows independently?
Because each array has a different size you will have to use a cell array: A = [1 1,0,1,1,0;0,0,1,0,0,1;0,0,0,1,1,1;1,1,1,1,1,1...

8 Tage ago | 1

| accepted

Answered
Not enough input arguments
You need to parameterize the objective function supplied to fsolve: https://www.mathworks.com/help/matlab/math/parameterizing-f...

8 Tage ago | 2

Answered
How to edit a number in a text file and save a copy of the file multiple times?
vec = [23,5]; % new values cnt = 0; rgx = '^(\s*\S+\s+)(\S+)(.+gamma.+)$'; f1d = fopen( 'input_matlab.txt','rt'); f2d = fope...

8 Tage ago | 1

| accepted

Answered
What function returns (as an integer) the number of bits in a data type or class, e.g. returns 16 for 'int16' or 'uint16' variables, 32 (or whatever) for 'float' types, etc.?
>> A = single(0); >> S = whos('A'); >> S.class ans = single >> S.bytes*8 ans = 32 If you have non-scalar arrays to get th...

9 Tage ago | 1

Answered
Find the index of given value in an array
Much simpler (and also works for multiple val values): interp1(array,1:numel(array),val) For example: >> array = [2,4,5,7,8,9...

9 Tage ago | 2

| accepted

Answered
realmax + 1 infinity?
Because the value 1 is nowhere near the smallest value that can be added to realmax to create a new value. You would need to add...

9 Tage ago | 3

| accepted

Answered
Function having string as argument
I would not recommend using a string to define the input function. A much more reliable way would be to write your code to acce...

9 Tage ago | 1

| accepted

Load more