Community Profile

# Stephen Cobeldick

##### Last seen: Today
7.343 total contributions since 2014

Suspensa Vix Via Fit

View details...

Contributions in
View by

why is the variable order in a user defined function important in lsqnonlin optimisation?
"Why does the order in the self defined function important for lsqnonlin fitting?" In some languages inputs can be specified by...

ongeveer 12 uur ago | 0

Finding and reporting the variable (Single number) of several with the largest value
The MATLAB approach is to use vectors/matrices (which is where the name MATLAB comes from): V = [0.0076,0.46,0.05]; C = ["A","...

ongeveer 17 uur ago | 0

Comma separated function output requests
Is this documented? [A{1:2}] = myone(1,2,3,4) % okay [B{1:1}] = myone(1,2,3,4) % okay [C{1:0}] = myone(1,2,3,4) % NARGOUT==0 ...

ongeveer 19 uur ago | 0

how can i avoid Nan in matlab expression and return 0
"if X is positive it must give 10, If X is negative it must give 5, If X is zero, it must give 0." X = randi([-3,3],1,9) % rand...

ongeveer 23 uur ago | 0

Sorting operation on a string matrix
s = ["1 9:53.3"; "3 9:23.5"; "5 2:16.2"; "2 2:45.6"; "4 12:01.2"]; [~,X] = sort(str2double(extractBefor...

1 dag ago | 1

| accepted

Assigning strings from struct variable
Use a comma-separated list: https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://www.mathworks...

1 dag ago | 2

Textscan Importing Multiple Inputs From One Text File
S = readlines('ResultA3forMatlabv2.txt'); F = @(s)sscanf(s,'%f,'); C = arrayfun(F,S,'uni',0) C{1:3} % the first few lines

2 dagen ago | 0

Print output if elements of a list match values in a column
A = [1;2;3;4;5;6;7;8;9;10]; B = ["A";"B";"C";"D";"E";"F";"G";"H";"I";"J"]; e = [3;6;8;10]; C = ["A";"A";"B";"F";"D";"H";"C";"...

3 dagen ago | 0

Why this code gives error?
Exactly as the plot documentation shows, the LineSpec must come directly after the X/Y data: plot(f,20*log10(FFT_abs/max(FFT_ab...

3 dagen ago | 0

Submitted

Hyphenate
Word hyphenation using Franklin Mark Liang's algorithm (aka Knuth-Liang algorithm). Used in TeX.

Save several results from recursive function
In my experience by far the easiest way to achieve this is to use a nested function, something like (pseudocode): function out ...

5 dagen ago | 0

| accepted

Why can't I put the 1x3 matrix into 1x3 variable?
"Why?" Because the square brackets have different meanings on the Left Hand Side (LHS) and Right Hand-Side (RHS) of the equals ...

5 dagen ago | 2

| accepted

How to use the parameters of other functions within the ‘cellfun’ function?
https://www.mathworks.com/help/matlab/math/parameterizing-functions.html f = @(a)smoothdata(a,'movemedian',100); x = cellfun(f...

7 dagen ago | 0

| accepted

I would like to compile a text string for each one of the three index of two given arrays
Simpler with compose: XX = [1,2,3,4.96875]; YY = [3,2,1,0]; fmt = "&DEVC ID=''vel_%g'', QUANTITY=''VELOCITY'', ABC=%d,0.0525,...

7 dagen ago | 0

| accepted

Submitted

Next Available Filename
Returns the next unused file or folder name. The name is created by incrementing a numbered suffix.

compare two vectors then insert missing element
Simpler: A=[ 1.000 0.5860 0.01403 2.500 0.7395 0.01277 3.500 0.8450 0.01146 4...

7 dagen ago | 0

Taking a string from a string array then identifying the characters within that string
A string array is a container class: it contains character vectors. Use curly braces to get the character vectors: w = ["aisle"...

8 dagen ago | 1

How can I use inputdlg() to store multiple variables and then use those variables in equations for later?
>> C = inputdlg(["m","b","k","x1","x2","F","w0"]) C = 7×1 cell array {'1.2'} {'2.3'} {'3.4'} {'4.5'} ...

8 dagen ago | 0

| accepted

Problem with vertically Concatenating vectors in a function
Rather than using a loop, a much better use of MATLAB would be to use comma-separated lists: https://www.mathworks.com/help/mat...

8 dagen ago | 0

| accepted

How to create table from struct array
Note that mixing up meta-data (the date) into fieldnames forces superfluous nesting of structures. This poor data design has alr...

9 dagen ago | 0

| accepted

Smallest positive number in MATLAB
eps(0) returns the smallest positive non-zero floating point number, which is denormal: format hex eps(0) Normal and denormal...

9 dagen ago | 2

| accepted

Submitted

Customizable Natural-Order Sort
Alphanumeric sort of a cell array of strings, with customizable numeric format.

Submitted

Natural-Order Filename Sort
Alphanumeric sort of filenames or filepaths, with customizable numeric format.

Submitted

Natural-Order Row Sort
Alphanumeric row sort of a cell array of strings, with customizable numeric format.

Understanding the structfun() or cellfun() commands
Avoiding CELLFUN or STRUCTFUN is simpler and much more efficient: S = dir('*_M.csv'); V = sscanf([S.name],'%f_M.csv')

11 dagen ago | 0

how can I store chars of a cells with different length in a matrix
C = cell(N,0); for k = 1:N tmp = ... the output of your function (cell vector) C(k,1:numel(tmp)) = tmp; end

13 dagen ago | 0

| accepted

How to run a matlab code for all folders in a directory?
"Is there a way to run tha matlab code for all the folders with automated manner? " Of course, just use DIR. For example: P = ...

13 dagen ago | 1

How to fscanf a text file of characters to a string array/vector, but not a 1x1 string?

14 dagen ago | 1

| accepted

..+(Vehicle9{index(9)})+... % ^ missing DOUBLE

15 dagen ago | 0

| accepted

read each line a text file using Matlab function
opt = {'Delimiter',{':',' '}}; fid = fopen('data.txt','rt'); nmc = nnz(fgetl(fid)==':'); frewind(fid); fmt = repmat('%s%f',1...

15 dagen ago | 1

| accepted