Answered

How can I dynamically index into a nested struct that contains cell arrays

Essentially you are attempting to write a MATLAB parser using MATLAB. Such a task is not trivial, but for a very limited subset ...

How can I dynamically index into a nested struct that contains cell arrays

Essentially you are attempting to write a MATLAB parser using MATLAB. Such a task is not trivial, but for a very limited subset ...

14 days ago | 0

| accepted

Answered

How can I delete two or more elements in a vector?

>> A = [1,1,2,3,10,7,10,1,5,3]; >> U = unique(A); >> Z = U(histc(A,U)==1) Z = 2 5 7

How can I delete two or more elements in a vector?

>> A = [1,1,2,3,10,7,10,1,5,3]; >> U = unique(A); >> Z = U(histc(A,U)==1) Z = 2 5 7

15 days ago | 1

| accepted

Answered

inputs of multi-variable functions?

"Is there a right order for input variables in a function?" Yes: MATLAB function inputs are positional: The 1st input provided...

inputs of multi-variable functions?

"Is there a right order for input variables in a function?" Yes: MATLAB function inputs are positional: The 1st input provided...

15 days ago | 0

| accepted

Answered

how to rearrange cell array with the grouped sequence

>> C = {21,3,'1';31,2,'1 1';25,1,'2 2 1 1'} C = [21] [3] '1' [31] [2] '1 1' [25] [1] ...

how to rearrange cell array with the grouped sequence

>> C = {21,3,'1';31,2,'1 1';25,1,'2 2 1 1'} C = [21] [3] '1' [31] [2] '1 1' [25] [1] ...

16 days ago | 0

Answered

How to simplify code which reads multiple files

You don't need to repeat the entire code, just the dir call is enough: theFiles = [... dir(fullfile(myFolder, '*ABC*.csv')...

How to simplify code which reads multiple files

You don't need to repeat the entire code, just the dir call is enough: theFiles = [... dir(fullfile(myFolder, '*ABC*.csv')...

16 days ago | 0

| accepted

Answered

imshow not working when going from unit8 to double

Most likely because you did not scale the image when you converted the type. uint8 images are treated as having values from 0 t...

imshow not working when going from unit8 to double

Most likely because you did not scale the image when you converted the type. uint8 images are treated as having values from 0 t...

17 days ago | 0

| accepted

Answered

Looping a function with different inputs and storing multiple outputs.

The very simple solution is to loop over indices, and not over data (like you are doing): V1 = 0.5:1:2.5; % data! V2 = 0.5:1:2...

Looping a function with different inputs and storing multiple outputs.

The very simple solution is to loop over indices, and not over data (like you are doing): V1 = 0.5:1:2.5; % data! V2 = 0.5:1:2...

17 days ago | 1

| accepted

Answered

Save and Load .mat files with different names that numerically go up automatically. Maybe in a for loop?

"...as long as there is a way to load multiple of these in one go, without them all overwriting each other as fvalagg" This is ...

Save and Load .mat files with different names that numerically go up automatically. Maybe in a for loop?

"...as long as there is a way to load multiple of these in one go, without them all overwriting each other as fvalagg" This is ...

17 days ago | 1

| accepted

Answered

How to use cellfun?

fun = @(x,y) fminbnd(@(c0)objfunc(y,deg(c0,x,'other input parameters')),cm,cM); [C,V] = cellfun(fun,XM,YM,'Uni',0)

How to use cellfun?

fun = @(x,y) fminbnd(@(c0)objfunc(y,deg(c0,x,'other input parameters')),cm,cM); [C,V] = cellfun(fun,XM,YM,'Uni',0)

17 days ago | 1

| accepted

Answered

Anonymous function to calculate a sum

>> fun = @(x,n) x + sum(x.^(2:2:2*n) ./ factorial(2:2:2*n)); >> fun(3,5) ans = 12.066 Compare against your expansion: >> x ...

Anonymous function to calculate a sum

>> fun = @(x,n) x + sum(x.^(2:2:2*n) ./ factorial(2:2:2*n)); >> fun(3,5) ans = 12.066 Compare against your expansion: >> x ...

17 days ago | 2

| accepted

Answered

how to open such files "File B -ASCII" saved from MATLAB?

The -ASCII option saves a double array as a text file with space delimiters. This means: Any text editor can open that text fil...

how to open such files "File B -ASCII" saved from MATLAB?

The -ASCII option saves a double array as a text file with space delimiters. This means: Any text editor can open that text fil...

17 days ago | 1

| accepted

Answered

How to read rows of data in .csv file and turn them into arrays?

Notes to consider when importing a large file: Importing as character and then doing any kind of text manipulation before conve...

How to read rows of data in .csv file and turn them into arrays?

Notes to consider when importing a large file: Importing as character and then doing any kind of text manipulation before conve...

17 days ago | 0

| accepted

Submitted

Hyphenate

Word hyphenation using Franklin Mark Liang's algorithm (aka Knuth-Liang algorithm). Used in TeX.

18 days ago | 6 downloads |

Answered

Display Value of a Slider in a text box without GUIDE

If you want the slider to update something (text, plot, anything) as it moves, then you will need to add a listener: https://ww...

Display Value of a Slider in a text box without GUIDE

If you want the slider to update something (text, plot, anything) as it moves, then you will need to add a listener: https://ww...

18 days ago | 0

| accepted

Answered

Parula color on matlab 2013a

https://www.mathworks.com/help/matlab/ref/colormapeditor.html

Parula color on matlab 2013a

https://www.mathworks.com/help/matlab/ref/colormapeditor.html

19 days ago | 1

Answered

Startup path issue creating variable errors

"How is it possible that I don't have a startup.m file on a clean install" Because it is a clean install: MATLAB does not creat...

Startup path issue creating variable errors

"How is it possible that I don't have a startup.m file on a clean install" Because it is a clean install: MATLAB does not creat...

19 days ago | 0

Answered

Function is not reading input from main script

You need to parameterize your function calls: https://www.mathworks.com/help/matlab/math/parameterizing-functions.html You nee...

Function is not reading input from main script

You need to parameterize your function calls: https://www.mathworks.com/help/matlab/math/parameterizing-functions.html You nee...

19 days ago | 0

| accepted

Answered

'combnk' enumeration of combinations

>> [X,Y,Z] = ndgrid([-1,0,1]); >> M = [Z(:),Y(:),X(:)] M = -1 -1 -1 -1 -1 0 -1 -1 1 -1 0 -1 -1 0 ...

'combnk' enumeration of combinations

>> [X,Y,Z] = ndgrid([-1,0,1]); >> M = [Z(:),Y(:),X(:)] M = -1 -1 -1 -1 -1 0 -1 -1 1 -1 0 -1 -1 0 ...

19 days ago | 0

| accepted

Answered

Problem with if-elseif when conditions contain several strings

"So I don't need a solution, but an explanation, why this occurs..." The first thing to do when trying to understand what your ...

Problem with if-elseif when conditions contain several strings

"So I don't need a solution, but an explanation, why this occurs..." The first thing to do when trying to understand what your ...

19 days ago | 1

| accepted

Answered

How to read a specific number in a text file containing a mixture of strings and numbers?

The regular expression doesn't need to be so complex: >> chr = webread('http://tgftp.nws.noaa.gov/data/observations/metar/decod...

How to read a specific number in a text file containing a mixture of strings and numbers?

The regular expression doesn't need to be so complex: >> chr = webread('http://tgftp.nws.noaa.gov/data/observations/metar/decod...

20 days ago | 0

Answered

How to load multiple specified variables in a specified mat file？

Your code does not make much sense: you added single quotes around the variable name (making it a literal string), you removed t...

How to load multiple specified variables in a specified mat file？

Your code does not make much sense: you added single quotes around the variable name (making it a literal string), you removed t...

20 days ago | 0

Answered

If B is a matrix,what is the difference between B(1:end) and B(:)

Given a matrix B: B(1:end) uses linear indexing. The size of the output is the same as the size of the index (which in your exa...

If B is a matrix,what is the difference between B(1:end) and B(:)

Given a matrix B: B(1:end) uses linear indexing. The size of the output is the same as the size of the index (which in your exa...

20 days ago | 2

| accepted

Answered

Variables accessible in unrelated files?

"Can someone explain to me how this is possible..." Because you have written scripts. Scripts share the same workspace that the...

Variables accessible in unrelated files?

"Can someone explain to me how this is possible..." Because you have written scripts. Scripts share the same workspace that the...

21 days ago | 0

Answered

How to extract elements form a vector in order to create an unknown number of sub-vectors?

Here is one simple approach based on diff, cumsum, and accumarray: >> M = [2.24;2.28;2.31;0.99;1.44;1.44;1.44;1.44;2.12;2.25;2....

How to extract elements form a vector in order to create an unknown number of sub-vectors?

Here is one simple approach based on diff, cumsum, and accumarray: >> M = [2.24;2.28;2.31;0.99;1.44;1.44;1.44;1.44;2.12;2.25;2....

21 days ago | 1

| accepted

Answered

Extracting strings between different characters from a cell array without loop

>> C = {'LS=Students201509DS=Teachers201509CS=ConfigVS=English]' 'LS=Preschoolers201801DS=Students201910CS=AbsVS=Italian]' ...

Extracting strings between different characters from a cell array without loop

>> C = {'LS=Students201509DS=Teachers201509CS=ConfigVS=English]' 'LS=Preschoolers201801DS=Students201910CS=AbsVS=Italian]' ...

22 days ago | 3

| accepted

Answered

how to determine the relative position of a number in a matrix

>> M = [1 0 0 0 % valid 1 0 0 1 % valid 1 0 0 -1 % valid 1 0 -1 0 % valid ...

how to determine the relative position of a number in a matrix

>> M = [1 0 0 0 % valid 1 0 0 1 % valid 1 0 0 -1 % valid 1 0 -1 0 % valid ...

23 days ago | 1

| accepted

Answered

Convert a vector to vector sequentially?

>> init = [1 2 3 4] >> final = [5 6 7 8] >> X = triu(ones(5,4)); >> M = init.*X + final.*~X M = 1 2 3 4 5 2...

Convert a vector to vector sequentially?

>> init = [1 2 3 4] >> final = [5 6 7 8] >> X = triu(ones(5,4)); >> M = init.*X + final.*~X M = 1 2 3 4 5 2...

24 days ago | 1

Answered

Loop function over multiple subfolders within one root folder?

The MATLAB documentation shows you can either obtain the names (i.e. using dir) or generate them (e.g. using sprintf): https://...

Loop function over multiple subfolders within one root folder?

The MATLAB documentation shows you can either obtain the names (i.e. using dir) or generate them (e.g. using sprintf): https://...

25 days ago | 0

Answered

turning date strings to overal minutes

Just use datetime, e.g.: >> C = {... '2019_12_31_17_43_31.39-Isd' '2019_12_31_17_19_36.39-Ig' '2019_12_31_16_55_41.38-Ig' '...

turning date strings to overal minutes

Just use datetime, e.g.: >> C = {... '2019_12_31_17_43_31.39-Isd' '2019_12_31_17_19_36.39-Ig' '2019_12_31_16_55_41.38-Ig' '...

25 days ago | 0

| accepted

Answered

Efficient way of finding numbers from one matrix in another, not using for loops

Your code's slowness is partly due to the fact that you are expanding the output array ElementNodes on each loop iteration: this...

Efficient way of finding numbers from one matrix in another, not using for loops

Your code's slowness is partly due to the fact that you are expanding the output array ElementNodes on each loop iteration: this...

25 days ago | 1

| accepted