Answered

Smallest positive number in MATLAB

eps(0) returns the smallest positive non-zero floating point number, which is denormal: format hex eps(0) Normal and denormal...

Smallest positive number in MATLAB

eps(0) returns the smallest positive non-zero floating point number, which is denormal: format hex eps(0) Normal and denormal...

13 dagen ago | 2

| accepted

Submitted

Customizable Natural-Order Sort

Alphanumeric sort of a cell array of strings, with customizable numeric format.

15 dagen ago | 56 downloads |

Submitted

Natural-Order Filename Sort

Alphanumeric sort of filenames or filepaths, with customizable numeric format.

15 dagen ago | 338 downloads |

Submitted

Natural-Order Row Sort

Alphanumeric row sort of a cell array of strings, with customizable numeric format.

15 dagen ago | 23 downloads |

Answered

Understanding the structfun() or cellfun() commands

Avoiding CELLFUN or STRUCTFUN is simpler and much more efficient: S = dir('*_M.csv'); V = sscanf([S.name],'%f_M.csv')

Understanding the structfun() or cellfun() commands

Avoiding CELLFUN or STRUCTFUN is simpler and much more efficient: S = dir('*_M.csv'); V = sscanf([S.name],'%f_M.csv')

16 dagen ago | 0

Answered

how can I store chars of a cells with different length in a matrix

C = cell(N,0); for k = 1:N tmp = ... the output of your function (cell vector) C(k,1:numel(tmp)) = tmp; end

how can I store chars of a cells with different length in a matrix

C = cell(N,0); for k = 1:N tmp = ... the output of your function (cell vector) C(k,1:numel(tmp)) = tmp; end

17 dagen ago | 0

| accepted

Answered

How to run a matlab code for all folders in a directory?

"Is there a way to run tha matlab code for all the folders with automated manner? " Of course, just use DIR. For example: P = ...

How to run a matlab code for all folders in a directory?

"Is there a way to run tha matlab code for all the folders with automated manner? " Of course, just use DIR. For example: P = ...

17 dagen ago | 1

Answered

How to fscanf a text file of characters to a string array/vector, but not a 1x1 string?

str = readlines('sample.txt')

How to fscanf a text file of characters to a string array/vector, but not a 1x1 string?

str = readlines('sample.txt')

18 dagen ago | 1

| accepted

Answered

Problem with adding integers

..+(Vehicle9{index(9)})+... % ^ missing DOUBLE

Problem with adding integers

..+(Vehicle9{index(9)})+... % ^ missing DOUBLE

19 dagen ago | 0

| accepted

Answered

read each line a text file using Matlab function

opt = {'Delimiter',{':',' '}}; fid = fopen('data.txt','rt'); nmc = nnz(fgetl(fid)==':'); frewind(fid); fmt = repmat('%s%f',1...

read each line a text file using Matlab function

opt = {'Delimiter',{':',' '}}; fid = fopen('data.txt','rt'); nmc = nnz(fgetl(fid)==':'); frewind(fid); fmt = repmat('%s%f',1...

19 dagen ago | 1

| accepted

Answered

how to insert fprintf value into GUI edit text box?

You need to use sprintf, not fprintf: sprintf creates a character vector/string (this is what you need). fprintf prints direct...

how to insert fprintf value into GUI edit text box?

You need to use sprintf, not fprintf: sprintf creates a character vector/string (this is what you need). fprintf prints direct...

22 dagen ago | 0

| accepted

Answered

Sorting the name field in dir command

You could download my FEX submission natsortfiles: >> S = dir('*.txt'); >> S.name ans = '1.txt' ans = '10.txt' an...

Sorting the name field in dir command

You could download my FEX submission natsortfiles: >> S = dir('*.txt'); >> S.name ans = '1.txt' ans = '10.txt' an...

22 dagen ago | 0

Answered

How to concatenate horizontally a cell into another cell based on a vector

X = [1,1,2,2]; C = {rand(3,2),rand(3,1),rand(3,2),rand(3,1)}; C{:} Method one: arrayfun F = @(x)[C{x==X}]; D = arrayfun(F,1...

How to concatenate horizontally a cell into another cell based on a vector

X = [1,1,2,2]; C = {rand(3,2),rand(3,1),rand(3,2),rand(3,1)}; C{:} Method one: arrayfun F = @(x)[C{x==X}]; D = arrayfun(F,1...

27 dagen ago | 1

| accepted

Answered

MAtrix Indexing with a vector that contains colon

The colons must be character, the numeric indices must be numeric (not char like you tried): A = rand(4,3,2,4,3,2,4,3,2,4,3,2);...

MAtrix Indexing with a vector that contains colon

The colons must be character, the numeric indices must be numeric (not char like you tried): A = rand(4,3,2,4,3,2,4,3,2,4,3,2);...

27 dagen ago | 0

| accepted

Answered

Extract string with regexp()

inp = {'$abc_in','def_in_hij_out[]','xyz'} out = regexprep(inp,{'_(in|out(\[\])?)?\>','\W+'},'')

Extract string with regexp()

inp = {'$abc_in','def_in_hij_out[]','xyz'} out = regexprep(inp,{'_(in|out(\[\])?)?\>','\W+'},'')

27 dagen ago | 0

| accepted

Answered

Add an array to a cell arrayn within a for loop

V = [321,123,145,908,123,13,1,643,16,134,212,674,121,222,11]; X = [3,7,11,15]; F = @(b,e)V(b:e); C = arrayfun(F,X(1:end-1),...

Add an array to a cell arrayn within a for loop

V = [321,123,145,908,123,13,1,643,16,134,212,674,121,222,11]; X = [3,7,11,15]; F = @(b,e)V(b:e); C = arrayfun(F,X(1:end-1),...

28 dagen ago | 0

| accepted

Answered

My plot comes up as a white graph with no line.

The basic problem is that this syntax if t==1,2,3,4,5; is equivalent to writing this (i.e. each expression is evaluated indepe...

My plot comes up as a white graph with no line.

The basic problem is that this syntax if t==1,2,3,4,5; is equivalent to writing this (i.e. each expression is evaluated indepe...

28 dagen ago | 0

| accepted

Answered

Conversion from string to numbers within table

Most likely you should fix the data importing, rather than messing around with converting strings. load('data.mat') T = varfun...

Conversion from string to numbers within table

Most likely you should fix the data importing, rather than messing around with converting strings. load('data.mat') T = varfun...

28 dagen ago | 0

Answered

Help with if statement in a calculation loop

The simplest and most efficient solution is to use MIN and MAX: x = 5 + randn(5,7)*1.5; x = x*1.3 + 0.5 x = min(max(x,1),10)...

Help with if statement in a calculation loop

The simplest and most efficient solution is to use MIN and MAX: x = 5 + randn(5,7)*1.5; x = x*1.3 + 0.5 x = min(max(x,1),10)...

28 dagen ago | 0

| accepted

Answered

When creating a vector why does the size change when using a variable vs using a value?

"How come the variable is exactly the same value but gives a different answer?" No, the values are not exactly the same. In on...

When creating a vector why does the size change when using a variable vs using a value?

"How come the variable is exactly the same value but gives a different answer?" No, the values are not exactly the same. In on...

30 dagen ago | 0

| accepted

Answered

Why 'PreserveFormat' in writetable returns error?

The 'PreserveFormat' option was added in R2020b: https://www.mathworks.com/help/matlab/release-notes.html?rntext=PreserveFormat...

Why 'PreserveFormat' in writetable returns error?

The 'PreserveFormat' option was added in R2020b: https://www.mathworks.com/help/matlab/release-notes.html?rntext=PreserveFormat...

ongeveer een maand ago | 0

| accepted

Answered

Using matfile to partially extra data still loads entire file into memory

Transpose the cell array (when it is created), so that you are accessing a contiguous part of the cell array: Data = obj.CellAr...

Using matfile to partially extra data still loads entire file into memory

Transpose the cell array (when it is created), so that you are accessing a contiguous part of the cell array: Data = obj.CellAr...

ongeveer een maand ago | 0

Answered

How to make textscan robust against non-matching lines?

str = fileread('data.txt'); tkn = regexp(str,'#HELLOMATHWORKS,([^,]+),(\S+)','tokens'); tkn = vertcat(tkn{:}) vec = str2doubl...

How to make textscan robust against non-matching lines?

str = fileread('data.txt'); tkn = regexp(str,'#HELLOMATHWORKS,([^,]+),(\S+)','tokens'); tkn = vertcat(tkn{:}) vec = str2doubl...

ongeveer een maand ago | 0

| accepted

Answered

How to import several csv files (Nan,numeric,text) for operate with them after

"I want the cells to be rename because I want to know to which station corresponds the data in each cell. As you can see I could...

How to import several csv files (Nan,numeric,text) for operate with them after

"I want the cells to be rename because I want to know to which station corresponds the data in each cell. As you can see I could...

ongeveer een maand ago | 1

Answered

Conversion to double from function_handle is not possible message

You define ome1, ome2, and ome12 as functions of 1 or 2 input arguments, but in some cases you do not call their function handle...

Conversion to double from function_handle is not possible message

You define ome1, ome2, and ome12 as functions of 1 or 2 input arguments, but in some cases you do not call their function handle...

ongeveer een maand ago | 0

| accepted

Answered

Extracting rows from table with specific digits

I changed your example data so that the first code string contains '2' but not in the 2nd position, to make a more thorough test...

Extracting rows from table with specific digits

I changed your example data so that the first code string contains '2' but not in the 2nd position, to make a more thorough test...

ongeveer een maand ago | 1

Answered

Assignment of variables by comma separated lists

"Why is that?" The answer is surprisingly simple: the explicit syntax X,Y,Z is considered as three separate evaluations, much...

Assignment of variables by comma separated lists

"Why is that?" The answer is surprisingly simple: the explicit syntax X,Y,Z is considered as three separate evaluations, much...

ongeveer een maand ago | 0

| accepted

Answered

How to delete certain strings with chaning numbers in a big data set

tmp = sprintf("page %d of 600",i); data_new4~=tmp Or ~strcmpi(data_new4,tmp) Note that you will want to replace the previous...

How to delete certain strings with chaning numbers in a big data set

tmp = sprintf("page %d of 600",i); data_new4~=tmp Or ~strcmpi(data_new4,tmp) Note that you will want to replace the previous...

ongeveer een maand ago | 0

Answered

Kilobytes to bytes conversion

The SI system defines "kilo". The SI definition of "kilo" means 1000, and has never defined it to mean 1024. Here are the SI pr...

Kilobytes to bytes conversion

The SI system defines "kilo". The SI definition of "kilo" means 1000, and has never defined it to mean 1024. Here are the SI pr...

ongeveer een maand ago | 1

| accepted

Answered

how can partition a vector into smaller sub sequences

A = 1:19; N = [3,5,7]; S = mat2cell(A(1:sum(N)),1,N) Or V = cumsum([0,N]); F = @(b,e)A(1+b:e); S = arrayfun(F,V(1:end-1),V...

how can partition a vector into smaller sub sequences

A = 1:19; N = [3,5,7]; S = mat2cell(A(1:sum(N)),1,N) Or V = cumsum([0,N]); F = @(b,e)A(1+b:e); S = arrayfun(F,V(1:end-1),V...

ongeveer een maand ago | 0

| accepted