Community Profile

# Stephen Cobeldick

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

Suspensa Vix Via Fit

View details...

Contributions in
View by

How can I use the split function with multiple delimiters?
>> str = 'software_logical/forIteratorSubsystem/Out1'; >> [one,two] = fileparts(str) one = software_logical/forIteratorSubsyst...

alrededor de 5 horas ago | 0

Simplify a string with MATLAB script
>> Eq = 'A_1+((A_2+A_3)&(A_4+A_5))+A_6'; >> Fq = regexprep(Eq, '^([A-Z]+_)(.*)', '\$1\(\${strrep(\$2,\$1,'''')}\)') Fq = A_(1+((2...

alrededor de 8 horas ago | 0

How to Set Specific Arg in Function
"I've tried seraching for how to change/edit/give a specific argument but I can't find it. I've tried the following options but ...

alrededor de 11 horas ago | 1

| accepted

How can i extract parameters from a vector at specific values
Use ismember: >> A = 1:10 A = 1 2 3 4 5 6 7 8 9 10 >> B = 11:20 B = 11 12 13 14 1...

alrededor de 13 horas ago | 0

| accepted

Extracting data from strings with varying delimiters and column widths
You can insert delimiters between those numbers, e.g. using regexprep: str = regexprep(str,' *(\d+?) *(\d{1,4}\.\d+)','\$1,\$2,')...

alrededor de 13 horas ago | 1

| accepted

How to delete the columns in a structure array
Where S is your structure: X = arrayfun(@(s)any(structfun(@numel,s)<10),S); S(X) = [] Tested: >> S = struct('A',{rand(1,99),...

alrededor de 14 horas ago | 0

Simplest way to save a vector to a variable with commas and braces
You can create a character vector: >> strrep(mat2str(a),' ',',') ans = [1,2,3,4,5] which you can save however you want. But t...

alrededor de 14 horas ago | 0

Sort certain matrix cells in a vector
Linear indexing: >> G = Start_Matrix([15;16;18;12;13;14]) G = 78.808 83.353 112.37 188.5 ...

alrededor de 16 horas ago | 0

How do I convert strings stored in a cell array to numbers?
Here is a faster solution (which also does not rely of the evil eval hidden inside of str2num): >> C = {'Name','2/8','3/7','7/8...

alrededor de 16 horas ago | 0

Use a cell array: N = s(1,1); C = cell(1,N); for k = 1:N C{k} = news(c,'Symbol',symbol(k),'Category',"Analyst Ratings");...

2 días ago | 0

combine 30.mat file having 1*15 matrix (Each .mat file having 1 row and 15 columns) to one .mat file
The best approach is to follow the examples in the MATLAB documentation: https://www.mathworks.com/help/matlab/import_export/pr...

2 días ago | 1

| accepted

Comparing cell with criteria
out1 = cellfun(@(l,r) setdiff(1:9,[l,r]), Spfcfef(:,1), Spfcfef(:,2), 'Uni',0); out2 = cellfun(@(l,r) setdiff(l,r), Spfcf...

2 días ago | 0

| accepted

Splitting a vector into separate vectors using thresholds
Simpler and more robust: >> x = [9,15,9,23,15,9,15,7,99,0,12] x = 9 15 9 23 15 9 15 7 99 ...

3 días ago | 0

| accepted

How can I import multiple .CSV files in MATLAB with no sequential filename?
P = 'relative/absolute path to the folder where the files are saved'; S = dir(fullfile(P,'*.csv')); for k = 1:numel(S) F...

3 días ago | 1

| accepted

Find function in matlab
find returns the indices of non-zero elements of an array. You provided find with a logical array with these values: >> a>10 a...

3 días ago | 2

| accepted

What is the best way to create a vector with a special sequence of subvectors
Store the vectors in one matrix, then you just need to use nchoosek to generate the required indices: >> M = randi(9,5,3) % eac...

3 días ago | 0

| accepted

Converting numbers into logicals
>> A = {[3;5;6;8],[2,3,5]}; % fake data >> B = cell2mat(cellfun(@(v)ismember(1:9,v),A(:),'UniformOutput',false)) B = 0 0 ...

3 días ago | 0

| accepted

Indexing a matrix with an array
Use a cell array, e.g.: C = {2,3}; % use NUM2CELL(I) if required. A(C{:}) Tested: >> A = rand(4,4) A = 0.340974 0.252...

4 días ago | 0

| accepted

Expanding the existing Matrix
Use repelem or kron, e.g. where V is your input vector: Z = repelem(V,24) or Z = kron(V,ones(24,1)) % adjust to suit V's orie...

4 días ago | 0

| accepted

How to concatenate a 3D cell array along the 3rd dimension?
In one line using num2cell, cellfun, and vertcat: >> C1 = cell(2,2,3); % preallocate cell array. >> C1(:) = cellfun(@(~)rand(1...

4 días ago | 0

| accepted

How to find the element of a number if that number were to be placed in an ordered list?
The robust solution: >> ida = find(list<number,1,'last') ida = 3 >> idb = find(list>number,1,'first') idb = 4

5 días ago | 2

| accepted

fprintf can't make new line
Try opening the file in text mode, not binary mode: A = 5; tcl = regexp(fileread('old_file.tcl'), '[\n\r]+', 'split')'; tcl{3...

5 días ago | 1

| accepted

Submitted

Number to Scientific Prefix
Convert a numeric value to an metric prefixed string (SI/engineering). Bonus: binary prefixes!

Submitted

Scientific Prefix to Number
Convert a metric prefixed string into numeric value (SI/engineering). Bonus: binary prefixes!

Same number of Rows and Cols of a matrix (N*N)
This will return false for non-square matrices, and also if ndims>2: isequal(0,diff(size(M))) It is easy to use with assert: ...

6 días ago | 0

complex plots bug?
"Am I doing something wrong or is this a bug in Matlab plotting?" There is no bug in the plotting. Exactly as documented, when...

6 días ago | 0

| accepted

How to store " first_element " values?
No loop needed, here using accumarray: >> A = [1,1,1,1,2,3,4,4,4;1,2,3,4,5,5,5,5,5] A = 1 1 1 1 2 3 4 4 4 ...

6 días ago | 2

Converting a matrix of strings to a txt file
the format string need to have 3 conversion operators (or as many as you want on each line). the matrix needs to be tranposed. ...

6 días ago | 1

| accepted

How to find duplicated values and calculate the mean of them?
Here is one solution: >> M = dlmread('all_velocities.txt'); >> [~,~,X] = unique(M(:,1:2),'rows'); >> F = @(x) mean(M(x,:),1)...

6 días ago | 0