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 ...

4 years 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...

4 years ago | 0

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

4 years 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

4 years 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...

4 years ago | 2

| accepted

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

4 years 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...

4 years 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...

4 years ago | 0

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

4 years 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; ...

4 years 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 ...

4 years ago | 0

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

4 years 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]+)>(...

4 years ago | 0

| accepted

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

4 years 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: ...

4 years 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},...

4 years 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...

4 years 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...

4 years 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) = []

4 years 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...

4 years ago | 2

| accepted

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

4 years ago | 0

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

4 years ago | 6

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)

4 years 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 ...

4 years ago | 0

| accepted

Answered
assign cell arrays to struct
You could use CELL2STRUCT : fnm = {'hello','world'}; val = {[1,NaN],[1,4,9]}; S2 = cell2struct(val,fnm,2) or a comma-separat...

4 years ago | 0

| accepted

Answered
how to find indices of duplicates in array and save results on a structure
A = [1;5;2;5;3;3;4;1;2;1]; [U,~,X] = unique(A); V = 1:numel(A); C = accumarray(X,V(:),[],@(v){v}); S = struct('value',num2ce...

4 years ago | 0

| accepted

Answered
Logical indexing cell array
That is an inefficient way to store and process that data. Using one numeric array would be simpler and much more efficient: M...

4 years ago | 1

Answered
Can you download individual images from the image labeling app onto an external hard drive?
"but I can't figure out a way to set the hard drive as the folder I want to save my images in" Don't. Do not set/change to oth...

4 years ago | 0

Answered
Help iteration for loop and tables vertcat
Using one cell array will be much simpler (and more efficient) than your approach of numbering the variable names: w = 1:10; % ...

4 years ago | 1

| accepted

Answered
Splitting table text column with multiple delimiters based on parantheses.
S = ["Player collected a YELLOW coin at (-5.5, 10.9, 90.1)";"Access to new world";"New world entered";"Player collected a GREEN ...

4 years ago | 1

| accepted

Load more