Community Profile # Stephen

Active since 2014

Suspensa Vix Via Fit

#### Statistics

All
• • • • • • • • • • • • #### Content Feed

View by

How to index array with an array?
u = [11,12,13;21,22,23;31,32,33] % Access element at row 2, column 1 id = [2,1] ic = num2cell(id); u(ic{:}) https://www.mat...

7 hours ago | 0

| accepted

How to I call specific values from a 45x1 Matrix?

1 day ago | 0

Assign a cell data that starts with a regular expression
Always LOAD into an output variable! That will make your code much more reliable, and makes this task easier. Method 1: the sim...

1 day ago | 0

| accepted

Removing zeros from matrix
A = [1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,0;1,2,3,4,0,0;1,2,3,0,0,0] Method one: NONZEROS and CELLFUN baz = @(v)v(end); fnh = @(...

1 day ago | 2

| accepted

How to distribute elements of a vector to each of output variable?
You can use a comma-separated list: x = [1,2,3,4,5]; c = num2cell(x); [a,b,c,d,e] = c{:} https://www.mathworks.com/help/matl...

1 day ago | 0

Explain why it makes sense that matrix A( :, :, 1) is two-dimensions, while A( :, 1, :) and A(1, :, :) return three dimensions
So far no one has really answered why this makes sense, which is what the original question asked. "My question was more about ...

2 days ago | 0

Create loop to load .mat file and store values to a matrix.
This should get you started. In the absence of any data desription I assumed that withinin each file x and y are scalar. You wil...

2 days ago | 0

Splitting a table using varagin
"The matlab documentation states that the first term in the bracket after splittaply should be a function such as @max" The SPL...

3 days ago | 0

| accepted

Use a ready p-file to operate on matrices
Your approach is complex, obfuscated, and inefficient. Using numbered variables is a sign that you are doing something wrong. R...

3 days ago | 1

| accepted

Convert time in decimal days into hh:mm:ss format
N = 0.504513888888889; T = days(N); T.Format = 'hh:mm:ss' or D = datetime(N,'ConvertFrom','excel'); T = timeofday(D)

4 days ago | 0

Extracting numerator and denominator values from a decimal value
[N,D] = rat(6.52) Multiply both by four if you want to.

4 days ago | 1

| accepted

Efficiently identifying a set of 1s: follow up question after months later
A simpler, more efficient, much more robust solution: a = [1,1,1,-1,0,0,0,0,1,1,-1,0,0,1,1,1,1,-1,0,0]; d = diff([false,a==1,f...

5 days ago | 0

| accepted

Any efficient way to identify a set of 1s in a big array?
A simple, efficient, robust solution: a = [1,1,1,-1,0,0,0,0,1,1,-1,0,0,1,1,1,1,-1,0,0]; d = diff([false,a==1,false]); s = fin...

5 days ago | 0

| accepted

Problem with datetime in German
There does seem to be a problem with DATETIME handling the period characters (below). Workaround: replace/remove the period cha...

6 days ago | 0

| accepted

Any advice that "you are going to need to read the file as text" is incorrect. It is much better to import and store numeric da...

6 days ago | 0

How to see if characters are present in a string array.
Assuming that all string elements contain exactly the same number of characters, then you can do this easily with basci logical ...

6 days ago | 0

| accepted

Subtracting Matrices in Special way
If the A values are copied first then only two ISMEMBER are required (simpler, more efficient), nor any resizing or changing of ...

7 days ago | 1

How do I get values of a certain parameter in a multi-dimensional matrix?
a(~Ind) = NaN

8 days ago | 0

| accepted

Display file names from current directory if more than n characters
n = 5; P = 'absolute or relative path to where the files are saved'; S = dir(fullfile(P,'*.*')); C = {S(~[S.isdir]).name}; % ...

8 days ago | 0

| accepted

Comparision double values 135 with 135.0000
" A comparision with a simple if-statement and the == operator does not succeed." Yes, it does succeed: their values are differ...

8 days ago | 0

| accepted

Submitted

Customizable Natural-Order Sort
Alphanumeric sort of a cell/string/categorical array, with customizable number format. Submitted

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

Natural-Order Row Sort
Alphanumeric row sort of a cell/string/categorical/table array, with customizable number format. Is it possible to fprintf/sprintf each row of elements in a vector using loop?
I would not use a loop: N = ["Earth"; "Venus"; "Mars"]; V = ["1.0000"; "0.8975"; "0.3915"]; fprintf('%s %s Gravity\n', [V(:),...

13 days ago | 2

| accepted

How can I import a file.txt and extract data?
opt = {'CollectOutput',true}; [fid,msg] = fopen('prova2.txt'); assert(fid>=3,'%s',msg) hdr = fgetl(fid); out = textscan(fid,...

13 days ago | 1

| accepted

Find values that are greater than a specific number in a table
nnz(Lake>=20)

13 days ago | 0

| accepted

Directly perform a multiplication on certain variables in a table
T = cell2table({'a',1,2;'b',3,4;'a',5,6},'VariableNames',{'x','y','z'}) idx = strcmp(T.x,'b'); T{idx,{'y','z'}} = T{idx,{'y','...

13 days ago | 0

| accepted

Recording vectors in for loop, when the loop is running in a range starting with negative numbers
Data are not indices, do not mix them up. V = -nmax:1:nmax; % data!!!! for k = 1:numel(V) % indices!!!!! n = V(k); % data...

13 days ago | 0

| accepted