Community Profile

photo

Stephen Cobeldick


5,501 2014 年以降の合計貢献数

Suspensa Vix Via Fit

Stephen Cobeldick's バッジ

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

詳細を表示...

貢献した分野
表示方法

回答済み
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...

約23時間 前 | 0

| 採用済み

回答済み
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...

1日 前 | 7

回答済み
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...

1日 前 | 1

| 採用済み

回答済み
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...

1日 前 | 0

回答済み
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(:,...

2日 前 | 0

回答済み
Adding certain 'parts' of two matrices
B(2:3,2:3) = A

2日 前 | 0

| 採用済み

回答済み
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

2日 前 | 2

回答済み
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...

2日 前 | 0

回答済み
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...

2日 前 | 5

質問


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...

2日 前 | 18 件の回答 | 30

18

回答

回答済み
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...

3日 前 | 1

| 採用済み

回答済み
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...

3日 前 | 0

回答済み
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...

3日 前 | 0

| 採用済み

回答済み
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 ...

3日 前 | 0

回答済み
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: ...

4日 前 | 1

| 採用済み

回答済み
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...

4日 前 | 0

| 採用済み

回答済み
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...

4日 前 | 1

| 採用済み

回答済み
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...

5日 前 | 1

| 採用済み

回答済み
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); ...

6日 前 | 0

回答済み
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,'-*')

6日 前 | 1

| 採用済み

回答済み
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]...

6日 前 | 1

回答済み
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...

6日 前 | 1

| 採用済み

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

7日 前 | 2

回答済み
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...

7日 前 | 1

| 採用済み

回答済み
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...

8日 前 | 1

回答済み
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...

8日 前 | 2

| 採用済み

回答済み
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...

8日 前 | 3

| 採用済み

回答済み
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...

8日 前 | 1

| 採用済み

回答済み
How can i create a new vector with conditions?
>> d = [100,200,300;250,350,450;810,550,600;500,700,400] d = 100 200 300 250 350 450 810 550 600 500 700 40...

8日 前 | 2

| 採用済み

回答済み
how to find similar points in two different matrices
Use ismembertol: >> X = ismembertol(M,N,'ByRows',true); >> C = M(X,:) C = 224 345

8日 前 | 0

| 採用済み

Load more