Community Profile Stephen

Active since 2014

Suspensa Vix Via Fit

Statistics

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

View by

Submitted

Convert a number to a string giving the value using Knuth's Myriad/Yllion naming scheme. How to save a matrix data with a concatenated variable name?
It is simpler and more efficient to use a structure: C = {'PrimSpeed','SecSpeed'}; S = struct(); for k = 1:numel(C) ...

environ 15 heures ago | 0

Find corresponding element in same row as given value in matrix
Assuming that A and B are you matrices, and that the Y values are in the second columns: [valA,idx] = max(A(:,2)) valB = B(idx...

3 jours ago | 0

What is the best practice to recursively extract data from a nested structure in matlab?
S=struct(); S.case='1'; S.type='A'; S.values.model1.case='2'; S.values.model1.type='C'; S.values.model1.values.mission.case...

6 jours ago | 0

| accepted

Identifying numbers within a long string containing multiple occurrences of text and numbers in one row
Simpler and gives the requested output: str = 'x y z p (Pa)...

6 jours ago | 0

| accepted

Read CSV with yyyyMMddhhmmss and group months
Here is one way to group by month only, ignoring empty lines of the CSV file: str = fileread('sample.csv'); tkn = regexp(str,'...

6 jours ago | 0

| accepted

using mat2cell
Using NUM2CELL would be simpler: C = num2cell(M,1) But if you insist on using MAT2CELL: C = mat2cell(M,1001,ones(1,10))

6 jours ago | 0

how can i negative all value in a matrix except diagonal?
M = [13.333,5,0,5,3.3333,0;5,27.333,4,10,3.3333,5;0,4,17.846,0,3.8462,10;5,10,0,17.5,2.5,0;3.3333,3.3333,3.8462,2.5,16.346,3.333...

7 jours ago | 1

| accepted

How to unfold/concatenate a 3D Matrix?
Making some guesses about the order you want, where A is your array: B = reshape(permute(A,[1,3,2]),[],21)

7 jours 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. Problem in properly creating a structure to store data
The simple and efficient approach: P = 'absolute or relative path to where the files are saved'; S = dir(fullfile(P,'*.txt'));...

8 jours ago | 0

Count number of unique .mat files in a folder
The simple MATLAB approach is to use one of the histogram functions rather than a loop, e.g.: % S = dir(fullfile(rootPath,'**',...

8 jours ago | 0

how to know if cell has some empty values
Where C is your cell array: any(cellfun(@isempty,C(:,3)))

8 jours ago | 1

| accepted

Find index of value extracted from subset in larger set
The simple MATLAB approach is to use indexing: X = 325:400; [p,Y] = min(pvalue(X)); t = tvalue(X(Y));

9 jours ago | 0

| accepted

How to use regexp in a cell array whose cells may contain cell entries
Your data: S = load('model.subSystems.mat'); model = S.model; Getting indices of nested cells which contain the requested tex...

9 jours ago | 0

| accepted

How can I create structure entries in a for loop.?
Using a cell array and a structure array: C = {data1,data2,data3}; for k = 1:numel(C) S(k).max = max(C{k}); S(k).min...

9 jours ago | 0

| accepted

elseif when the flag is not true
" I wanted the else condition to happen only when count1==5*N and the flag condition was not respected." Make the code explicit...

10 jours ago | 1

| accepted

colon operator returns different answer in command window and script
"colon operator returns different answer in command window and script" Yes, because you called COLON with different values. "W...

11 jours ago | 1

Removing certain type of repeating cell
A direct, intuitive, and reasonably efficient approach is to simply check the existing cell array content: out = Conc(5) fun...

12 jours ago | 0

| accepted

Read .txt file into a matrix and remove unwanted text
Simpler: str = fileread('N2_trace.txt'); tkn = regexp(str,'^(\d+)\.?\d*:[^:]+:\s+([^\n]+)','tokens','lineanchors'); tkn = ver...

12 jours ago | 1

| accepted

How can I check if it is a string?
The simplest approach is to use ISNAN, because STR2DOUBLE will return NaN for any input that it cannot convert to numeric: if i...

15 jours ago | 1

| accepted

Selecting a specific part in a string array
tmp = split(strg_cell(i,1)); x3(i,:) = tmp([1,end]); The MATLAB approach would be to use a simple FOR loop, rather than painfu...

18 jours ago | 0

Using Textscan to read Sinex file rows with variable delimiters
This is a fixed-width file, especially e.g. the presence of space characters in the location names indicates this. The header un...

18 jours ago | 0

| accepted

How to change a Data Series contained with Repeated NaNs to become other sequence of NaNs?
A = [NaN, NaN, NaN, 0, 0, NaN, NaN, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN, NaN] X = diff([isnan(A),false])<0; A(X) = 0

18 jours ago | 1

| accepted

when using listdlg is it possible to use tex characters in the ListString?
With recent MATLAB versions and OSs you can just use σ: listdlg('ListString' , {'Von Mises Stress', 'σ_x' , 'σ_y'}) E.g. R2018...

18 jours ago | 0

Removing element of array at random
a = 0; b = 1; rn = b*randn(200,1)+1; ix = randperm(200,10) % indices of elements to remove rn(ix) = []; % remove elements

18 jours ago | 0

| accepted

How to place a value in a function
F_x is an array, not a function (in the MATLAB sense: https://www.mathworks.com/help/matlab/function-basics.html) To access ele...

18 jours ago | 0

| accepted