Submitted

Round to Electronic Component Values

Round numeric array values to the best matching IEC 60063 resistor values (E-Series).

17 days ago | 7 downloads |

Answered

determining spaces between two strings in fprintf function

fprintf('%*s %*s\n',10,' G',5,' G');

determining spaces between two strings in fprintf function

fprintf('%*s %*s\n',10,' G',5,' G');

17 days ago | 1

| accepted

Answered

How can I iterate obtaining numbers?

You can use dynamic fieldnames: https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variables.html for...

How can I iterate obtaining numbers?

You can use dynamic fieldnames: https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variables.html for...

17 days ago | 0

Answered

How to merger multiple .mat files consists of 2D matrix into 3D matrix

Using the files from your comment, and assuming that the filenames all use sufficient leading zeros: D = '.'; % absolute or rel...

How to merger multiple .mat files consists of 2D matrix into 3D matrix

Using the files from your comment, and assuming that the filenames all use sufficient leading zeros: D = '.'; % absolute or rel...

19 days ago | 1

Answered

How to store all outputs from this nested for loop

Vs = 0:9; % Variable 1 Vom = 0.1:0.1:1; % Variable 2 Vmu = 0.1:0.1:1; % Variable 3 Ns = numel(Vs); Nom = numel(Vom); Nmu = ...

How to store all outputs from this nested for loop

Vs = 0:9; % Variable 1 Vom = 0.1:0.1:1; % Variable 2 Vmu = 0.1:0.1:1; % Variable 3 Ns = numel(Vs); Nom = numel(Vom); Nmu = ...

20 days ago | 0

| accepted

Answered

How to convert "cell array" to "character array"

C = {'A1','B1','C1'} D = vertcat(C{:}) or D = char(C)

How to convert "cell array" to "character array"

C = {'A1','B1','C1'} D = vertcat(C{:}) or D = char(C)

21 days ago | 0

Answered

how to extract a field from a nested structure, modify it, and write it back

As this information is missing in your question, I will assume that ALL is a scalar structure. fun = @(n)struct('dur',n, 'typ',...

how to extract a field from a nested structure, modify it, and write it back

As this information is missing in your question, I will assume that ALL is a scalar structure. fun = @(n)struct('dur',n, 'typ',...

22 days ago | 0

Answered

Multiply matrix by each element of a vector without a for loop

Let MATLAB do the heavy lifiting for you! Note that RESHAPE operations are computationally cheap as they do not change the array...

Multiply matrix by each element of a vector without a for loop

Let MATLAB do the heavy lifiting for you! Note that RESHAPE operations are computationally cheap as they do not change the array...

22 days ago | 0

Answered

Covert a cell with the same indices into individual matrices

It is not clear to me why you need to split the numeric data into 100 4x4 matrices, just to recombine the numeric data into 16 1...

Covert a cell with the same indices into individual matrices

It is not clear to me why you need to split the numeric data into 100 4x4 matrices, just to recombine the numeric data into 16 1...

22 days ago | 1

| accepted

Answered

read mat files with specific and dynamic name format and import data

The best approach is to use the same structure as DIR returns. This has the benefit that the filenames and filedata are automati...

read mat files with specific and dynamic name format and import data

The best approach is to use the same structure as DIR returns. This has the benefit that the filenames and filedata are automati...

23 days ago | 0

| accepted

Answered

How to subtract number inside cell

A = {[32,28,30,31],[27,29,30]}; B = {[30,64,72,85],[15,33,62]}; C = cellfun(@minus,A,B,'uni',0)

How to subtract number inside cell

A = {[32,28,30,31],[27,29,30]}; B = {[30,64,72,85],[15,33,62]}; C = cellfun(@minus,A,B,'uni',0)

24 days ago | 0

Answered

How to take a number inside cell array

A = {[32,28,30,31],[27,29,30],[32,29,31,27,28]}; B = {[30,64,72,85],[15,33,62],[45,62,77,84,90]}; F = @(a,b)b(max(a)==a); C =...

How to take a number inside cell array

A = {[32,28,30,31],[27,29,30],[32,29,31,27,28]}; B = {[30,64,72,85],[15,33,62],[45,62,77,84,90]}; F = @(a,b)b(max(a)==a); C =...

24 days ago | 0

| accepted

Answered

How to select array elements based on the elements of another array?

idx = ismembertol(eyetimes,spiketimes,0.02, 'DataScale',1); out = eyetimes(idx)

How to select array elements based on the elements of another array?

idx = ismembertol(eyetimes,spiketimes,0.02, 'DataScale',1); out = eyetimes(idx)

24 days ago | 0

| accepted

Answered

How can I solve an ODE with changing variable over time ?

Replace your Tset function with this: P = 'absolute or relative path to where the mat file is saved'; F = 'name of the mat fil...

How can I solve an ODE with changing variable over time ?

Replace your Tset function with this: P = 'absolute or relative path to where the mat file is saved'; F = 'name of the mat fil...

25 days ago | 0

| accepted

Answered

save for loop variable in workspace

Given that you are apparently incrementing your own loop counter then presumably you have a WHILE loop. In that case, try this:...

save for loop variable in workspace

Given that you are apparently incrementing your own loop counter then presumably you have a WHILE loop. In that case, try this:...

28 days ago | 0

Answered

How can I make a variable span multiple functions for nested structuring?

How to make a variable "cyan" (these are called shared variables) is explained here: https://www.mathworks.com/help/matlab/matl...

How can I make a variable span multiple functions for nested structuring?

How to make a variable "cyan" (these are called shared variables) is explained here: https://www.mathworks.com/help/matlab/matl...

28 days ago | 0

| accepted

Answered

Text file generated using MATLAB has invalid characters in it.

Get rid of the SAVE command. It is not completely clear why you added SAVE, but it is writing binary data into the same file th...

Text file generated using MATLAB has invalid characters in it.

Get rid of the SAVE command. It is not completely clear why you added SAVE, but it is writing binary data into the same file th...

28 days ago | 1

| accepted

Answered

Splitting a file into multiple files and need to generate file names from the individual files

whf = fileread('./testsplit.txt'); spl = regexp(whf,'\s+#Z\s+','split'); % more robust than just 'Z' for k = 2:numel(spl) % fi...

Splitting a file into multiple files and need to generate file names from the individual files

whf = fileread('./testsplit.txt'); spl = regexp(whf,'\s+#Z\s+','split'); % more robust than just 'Z' for k = 2:numel(spl) % fi...

29 days ago | 0

| accepted

Answered

How to use effectively use the lazy quantifier for regular expression?

regexp('4223594459854','4.*?4','match')

How to use effectively use the lazy quantifier for regular expression?

regexp('4223594459854','4.*?4','match')

29 days ago | 0

| accepted

Answered

how to put the same value in a number of lines in the first column of a matrix and different values in the second column (values coming from vectors)

The simple MATLAB approach is to leverage NDGRID: v1 = 1:1:2; v2 = 1:1:4; [m2,m1] = ndgrid(v2,v1); m = [m1(:),m2(:)] Can be...

how to put the same value in a number of lines in the first column of a matrix and different values in the second column (values coming from vectors)

The simple MATLAB approach is to leverage NDGRID: v1 = 1:1:2; v2 = 1:1:4; [m2,m1] = ndgrid(v2,v1); m = [m1(:),m2(:)] Can be...

30 days ago | 1

Answered

How to input image in array?

The simplest solution is to just store the image data in the same structure that DIR returns: S = dir(fullfile(myFolder,'*.bmp'...

How to input image in array?

The simplest solution is to just store the image data in the same structure that DIR returns: S = dir(fullfile(myFolder,'*.bmp'...

30 days ago | 0

| accepted

Answered

Delete columns in a structure array

Assuming that the data in f10 is scalar numeric (you did not tell us this important information): idx = [Data.f10]>10; Data = ...

Delete columns in a structure array

Assuming that the data in f10 is scalar numeric (you did not tell us this important information): idx = [Data.f10]>10; Data = ...

1 month ago | 0

| accepted

Answered

Using audioread to read a sequence of files and then combine

Do NOT use EVAL for trivial code like this. Use FULLFILE instead of concatenating text together. P = 'C:\Users\24hr sound anal...

Using audioread to read a sequence of files and then combine

Do NOT use EVAL for trivial code like this. Use FULLFILE instead of concatenating text together. P = 'C:\Users\24hr sound anal...

1 month ago | 0

Answered

How to add new cell array into a old struct

[STC_ORE.ore_ton] = ORE_TON{:}; [STC_ORE.x_cent] = X_CENT{:}; [STC_ORE.y_cent] = Y_CENT{:}; [STC_ORE.z_cent] = Z_CENT{:}; ht...

How to add new cell array into a old struct

[STC_ORE.ore_ton] = ORE_TON{:}; [STC_ORE.x_cent] = X_CENT{:}; [STC_ORE.y_cent] = Y_CENT{:}; [STC_ORE.z_cent] = Z_CENT{:}; ht...

1 month ago | 0

| accepted

Answered

Is there a one-line code for this?

A = [1 1;2 2;3 3;4 4;5 5]; A = [A;A+(0:1)]

Is there a one-line code for this?

A = [1 1;2 2;3 3;4 4;5 5]; A = [A;A+(0:1)]

1 month ago | 1

| accepted

Answered

replacing a matrix in loop

Do NOT use a loop for this! Do NOT expand any arrays inside loops! A simpler and much more efficient approach using a comma-sep...

replacing a matrix in loop

Do NOT use a loop for this! Do NOT expand any arrays inside loops! A simpler and much more efficient approach using a comma-sep...

1 month ago | 0

Answered

Create a cell array from matrices using for loop

x1 = rand(10,10); y1 = rand(10,10); z1 = rand(10,10); r1 = rand(10,10); a1 = cat(3,x1,y1,z1,r1); x2 = rand(10,10); y2 = ra...

Create a cell array from matrices using for loop

x1 = rand(10,10); y1 = rand(10,10); z1 = rand(10,10); r1 = rand(10,10); a1 = cat(3,x1,y1,z1,r1); x2 = rand(10,10); y2 = ra...

1 month ago | 1

| accepted

Answered

How can I automate the code to run a series of files in a folder?

P = 'G:\.shortcut-targets-by-id\1332UW1v7_g1_AsDgTVQW_dgb0LzbQ4Ni\Elizabeth-Data-Analysis-Spring-2021'; N = 64; % total number ...

How can I automate the code to run a series of files in a folder?

P = 'G:\.shortcut-targets-by-id\1332UW1v7_g1_AsDgTVQW_dgb0LzbQ4Ni\Elizabeth-Data-Analysis-Spring-2021'; N = 64; % total number ...

1 month ago | 0

| accepted

Answered

For loop getting array name

Your approach is leading you up the garden path. It is simpler to use indexing: P = 'absolute or relative path to where the fil...

For loop getting array name

Your approach is leading you up the garden path. It is simpler to use indexing: P = 'absolute or relative path to where the fil...

1 month ago | 0

Answered

How to convert the values greater than one to less than one for a matrix stored in workspace

M = [1.345, 1.678, 2.345, 3.456, 4.456] M = mod(M,1)

How to convert the values greater than one to less than one for a matrix stored in workspace

M = [1.345, 1.678, 2.345, 3.456, 4.456] M = mod(M,1)

1 month ago | 0