Community Profile

# Stephen Cobeldick

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

Suspensa Vix Via Fit

View details...

Contributions in
View by

how to use function "find" over matrices
"find the first value in each column which lis ess than 0.25 but greater than 0.2." >> x = rand(13,7) x = 0.833676 0.654...

etwa 6 Stunden ago | 1

| accepted

Struct to numeric variable
Apparently you have a 446x1 or 1x446 structure array, where the field in question contains a row vector. To concatenate all of t...

etwa 21 Stunden ago | 0

How to raise a decimal numbers as power of A??
Either use a loop or cellfun: >> A = [1,5,3;4,5,9;7,8,9]; >> V = 0.1:0.11:10; >> C = arrayfun(@(n)A^n,V,'uni',0); And checki...

2 Tage ago | 1

How to find and replace the content of an array
>> C = {'03/07/2019' '03/07/2019 00:30:00'}; >> X = cellfun('length',C)==10; >> C(X) = strcat(C(X),' 00:00:00') C = 03/07/2...

2 Tage ago | 0

How to load files in order
Use either of the methods shown in the documentation: https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of...

2 Tage ago | 0

| accepted

How to create an array with repeating values of a vector
m = repmat(v,20,1) or m = v(ones(1,20),:) or m = ones(20,1)*v or m = zeros(20,1)+v % requires >=R2016b or [~,X] = ndgrid...

3 Tage ago | 0

| accepted

Function like "find" but for lines
>> B = find(A.').' B = 1 2 4 5 6 9 11 12

3 Tage ago | 1

| accepted

How can I remove identical cell entries containing small arrays
Two efficient loops, no third-party functions: S = load('example.mat'); C = S.connect_group; N = numel(C); X = true(1,N); f...

3 Tage ago | 1

| accepted

Matrix split in vector
>> B = nonzeros(A.') B = 1 2 3 4 5 6 7 8

3 Tage ago | 0

| accepted

Import data as a structure array from a text file with different titles in the middle.
opt = {'MultipleDelimsAsOne',true}; out = {}; [fid,msg] = fopen('datafile.txt','rt'); assert(fid>=3,msg) while ~feof(fid) ...

4 Tage ago | 0

| accepted

Generate multiple matrices based on multiple inputs
P = 'Select which type(s) you would like: 1, 2 or 3. For multiple, seperate numbers with a space.'; C = inputdlg(P); V = sscan...

4 Tage ago | 1

| accepted

How to convert string "26/7" into a double variable?
>> str = '26/7'; >> vec = sscanf(str,'%f/%f'); >> vec(1)./vec(2) ans = 3.7143 One line (but I would not recommend using thi...

6 Tage ago | 2

How to save cell array of workspace vars into mat?
save('test.mat', vars{:}) How it works: https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://...

7 Tage ago | 1

| accepted

Simple Matrix Reduction Question. Ones and Zeros.
Simpler: >> [B,~] = find(A.') B = 4 1 2 3

9 Tage ago | 1

How do I match nested parenthesis (brackets, or braces) with dynamic regular expressions?
This matches the outer-most matched pair of parentheses: >> str = 'asdf (( dwer e: ( asdedsdskek))::)asd fg ( qwe 4 dfy5 57) q3...

9 Tage ago | 2

| accepted

Converting txt file string to matrix.
>> str = '{co-ordinates 1.5 2.5 4.8 weighting 11.7}{co-ordinates 2.5 2.8 1.7 weighting 21.4}{co-ordinates 1.5 2.5 4.8 weig...

10 Tage ago | 0

| accepted

I am trying to run this script, but it only returns the last part of the switch- the otherwise part, please help...
Your switch condition will not work as you expect. If you want to use logical comparisons for the case values, then you will nee...

10 Tage ago | 0

Calling a nested function from a dynamic regular expression throws an error
The best and most general workaround I have found so far is to call regexp from a local function, with function handles to the n...

11 Tage ago | 0

how to center a string
str = '23'; num = 9; tmp = (num-numel(str))/2; out = sprintf('%*s%*s',fix(tmp)+numel(str),str,ceil(tmp),'')

13 Tage ago | 0

"My question is why the term 1.0e-05 * appearing?" Because you are displaying the values in the command window using long forma...

15 Tage ago | 0

| accepted

How to filter a structure array based on a numeric value from a field?
You will need to concatenate the comma-separated list into one numeric array, e.g.: trips([trips.dir_id] == 1); % ^ ...

15 Tage ago | 0

| accepted

how would I add several matrices into one? (assembling global stiffness matrix for FEA)
This is easy when you store all of the matrices in one cell array, then you just need a simple for loop: >> C = {[1,1;1,1],[1,1...

15 Tage ago | 1

| accepted

Adding numbers in array in a specific order
>> [~,~,X] = unique(a); >> d = accumarray(X(:),b(:)) d = 81 122 245 985 2663

16 Tage ago | 0

| accepted

How can I sample n elements from each column of a matrix?
>> X = sub2ind([4,5],randi(4,2,5),[1:5;1:5]); >> B = A(X) B = 3 8 9 13 20 3 7 10 15 20

16 Tage ago | 0

How to call a function
Make these changes: clear,clc,close all % <-------- DELETE THIS AWFUL ANTIPATTERN LINE OF EVIL function [C1, C2, C3, C4, C5, s...

16 Tage ago | 0

| accepted

Passing extra output arguments from ode
"In summary my question is, how do I obtain f for the same time instants at which x is obtained." Using a persistent variable o...

16 Tage ago | 0

| accepted

why matlab always show my equation as matrix dimension
Most likely you need to follow the advice given in the error message and use array operations, e.g.: y = (668.061./x).*(-39-exp...

17 Tage ago | 0

This only reads one cell: "Range",'B3:B3' There is nothing in your code that reads "all non empty cells in col B starting from...

18 Tage ago | 0

| accepted