Answered
How to find the index of the first element which is greater than a particular value in a matrix for all the columns.
N = 5; M = randi(9,5,7) Method one: CUMSUM and FIND: X = M>N; X = X & cumsum(X,1)<2; [R,~] = find(X) Method two: FIND and ...

19 days ago | 1

| accepted

Answered
Strings are converted to cells during readtable
The simple solution is to specify the TEXTTYPE option when importing: data = table("string1", "string2"); writetable(data, "da...

20 days ago | 2

| accepted

Answered
Local functions are not working in MatLab R2022a
"I select it all and press F9." That will not work. You need to run the script by calling it by name from the command line: >...

20 days ago | 1

| accepted

Answered
fprintf within a for / if environment with crazy behaviour
The file is opened with fopen(fileID,'wt')" Perhaps, but in any case, you did not provide the file identifier to FPRINTF. "Wha...

20 days ago | 2

| accepted

Answered
How to extract hour+minute from DateTime vector ?
D = datetime(2016,4,5,[8;11],43,11) isAMRush = isbetween(timeofday(D),duration(7,45,0),duration(8,45,0))

21 days ago | 0

| accepted

Answered
Error usin .* Too many output arguments. How to save three variables at the same time in a loop?
Do not use separate variables with names Va, Vb, Vc, etc. The name MATLAB comes from "MATrix LABoratory". MATLAB is designed to ...

21 days ago | 1

| accepted

Answered
Remove element in multidimensional cell array
You used the wrong type of brackets. You used curly braces to place an empty array inside one cell. The reason why you wrote tha...

21 days ago | 0

Answered
2020a readtable error when specifying rectangular range
'DataRange','C2:F4', 'VariableNamesRange','C1:F1'

21 days ago | 0

| accepted

Answered
How to remove a range of rows from all nested structures of a parent structure?
s.a.fa = [1,2,3]; s.a.fb = [7,8,9]; s.a.fn = [4,5,6]; s.a s.a = structfun(@(v)v(1),s.a, 'uni',0); s.a

21 days ago | 0

| accepted

Answered
How to extract matches from results of a regexp match
"But the result is a cell array of cells (not sure why):" Summary: you need to use the ONCE option. Explanation: There are two...

22 days ago | 1

| accepted

Answered
How to extract big size of matrix from workspace to editor?
https://www.mathworks.com/help/matlab/ref/mat2str.html

23 days ago | 0

Answered
How to name variables in a loop?
Use a cell array: https://www.mathworks.com/help/matlab/cell-arrays.html n = 100; C = cell(1,n); for k = 1:n .. run your...

25 days ago | 1

| accepted

Answered
Looping with datetime greater and less than 24 hour
The simple and efficient approach is to use REM: a = duration([0; 0; 24; 0; -24], [22; 52; 6; 1; -5], [0; 0; 0; 0; 0]) b = rem...

26 days ago | 0

Answered
Seperate string and number
T = 'ADC1: 123.7834 1.0139'; V = sscanf(T,'ADC1:%f%f',[2,Inf]).'

26 days ago | 0

| accepted

Answered
Loop which Checks Values of Matrix
Forget about loops, learn the MATLAB approach using indexing: c = 1; W = [4,3,5,2,3]; M = [2.7,1.9,0.75,0.16,0.35] X = M>c; ...

27 days ago | 1

| accepted

Answered
matlab reads only first part of big textfile
Although the lines have differing lengths in these badly formatted files, we can observe: each line consists of the same block ...

27 days ago | 0

Submitted


Round to Electronic Component Values
Round numeric array values to IEC 60063 resistor/capacitor values (E-Series).

27 days ago | 12 downloads |

Thumbnail

Answered
How to write my for loop data into an array
Maxes = cell(1,grp); for k = 1:grp .. Maxes{k} = max(Array); end Maxes = vertcat(Maxes{:}); % optional

27 days ago | 0

Answered
string text manipulation - adding data based on previous data in the string
T = 'Time,<Message_CMD>element1,<other_meesage>elemenX,<Message_CMD>element2,<Message_RPT>element3' U = regexprep(T,'([A-Z]+)>(...

27 days ago | 0

| accepted

Answered
How to populate a tree with a struct with different depth?
https://www.mathworks.com/matlabcentral/fileexchange/42487-struct2tree

27 days ago | 0

| accepted

Answered
Problem with indexing a series of ranges
Use MAX's "linear" option: M = randi(9,5,7) [V,X] = max(M, [], 'linear') To be robust you should also specify the dimension: ...

27 days ago | 0

| accepted

Answered
Hi, I want to eliminate duplicates in a cell array in Matlab
T = {[1,2,5], [1,2,5], [1,3,5], [1,4,5], [2,4,5], [4,6]} for ii = numel(T):-1:2 for jj = 1:ii-1 if isequal(T{ii},...

27 days ago | 0

Answered
How to get the number in the cell containing the letter and space
No indirect, fragile, round-about conversion to other data classes is required. Here are two direct approaches: a = {'AABB 0100...

27 days ago | 1

| accepted

Answered
Splitting columns based on comma
raw.Position = {'';'';'';'(-6.9, 4.8, 68.4)';'(-8.5, 3.1, 18.0)';'(13.5, 2.5, 70.1)';'';''}; tmp = sscanf(sprintf('%s',raw.Posi...

28 days ago | 0

| accepted

Answered
Delete all repeatation number
a = [1,2,2,3,2,4,5,6,7,8,6]; [c,x] = histc(a,unique(a)); a(c(x)>1) = []

28 days ago | 3

Answered
How do I split a string using a only *single* whitespace delimiter so any multiple whitespaces are also "split"?
Here are a few approaches using regular expressions, note that 'split' vs 'match' etc. may have different behaviors in case of l...

30 days ago | 2

Answered
print value in open form
format short G format long G

1 month ago | 0

Answered
converting atan2 output to 360 deg
The simple, robust, and efficient solution is to use MOD: mod(atan2d(Y,X),360)

1 month ago | 1

Answered
Storing elements of product in a row matrix and extracting the nonzero elements
x = 1:3; y = 4:6; z = 7:9; [X,Y,Z] = ndgrid(x,y,z); A = nonzeros(X.*Y.*Z)

1 month ago | 0

Answered
How to converting complex numbers to absolute values?
No need for slow fiddling around with imported text via CELLFUN or evil EVAL. Just specify the delimiter&whitespace and MATLAB ...

1 month ago | 0

| accepted

Load more