Answered

storing data in a matrix from a nested loop

No loops required: >> d1 = [0,0,2;0,0,-2] d1 = 0 0 2 0 0 -2 >> d2 = [0,0,15;0,0,13] d2 = 0 ...

storing data in a matrix from a nested loop

No loops required: >> d1 = [0,0,2;0,0,-2] d1 = 0 0 2 0 0 -2 >> d2 = [0,0,15;0,0,13] d2 = 0 ...

11 días ago | 1

Answered

could anyone help me to calculate the euclidean distance for the matrix.

>> B = sqrt(sum(bsxfun(@minus,permute(A,[1,3,2]),permute(A,[3,1,2])).^2,3)) B = 0.00000 2.99851 2.56248 0.72363 2...

could anyone help me to calculate the euclidean distance for the matrix.

>> B = sqrt(sum(bsxfun(@minus,permute(A,[1,3,2]),permute(A,[3,1,2])).^2,3)) B = 0.00000 2.99851 2.56248 0.72363 2...

11 días ago | 0

| accepted

Answered

image the same and different

You swapped the order of the output arguments when you called the function. Here is the function definition: function [transfo...

image the same and different

You swapped the order of the output arguments when you called the function. Here is the function definition: function [transfo...

12 días ago | 0

| accepted

Answered

Subtract raws of a matrix from an array

MATLAB versions prior to R2016b: >> C = bsxfun(@minus,Q,M) C = 9 4 11 5 7 5 6 9 9 9 11 7...

Subtract raws of a matrix from an array

MATLAB versions prior to R2016b: >> C = bsxfun(@minus,Q,M) C = 9 4 11 5 7 5 6 9 9 9 11 7...

12 días ago | 0

| accepted

Answered

Count the number of same elements in an array

Your 1st example: >> V = [ 1 2 4 3 4 2 3 5 6 4 5 6 8 4 2 3 5 7 8 5 3 1 3 5 7 8 9 5 3 2 4 6 7 8]; >> C = hist(V,1:max(V)) C = ...

Count the number of same elements in an array

Your 1st example: >> V = [ 1 2 4 3 4 2 3 5 6 4 5 6 8 4 2 3 5 7 8 5 3 1 3 5 7 8 9 5 3 2 4 6 7 8]; >> C = hist(V,1:max(V)) C = ...

12 días ago | 2

Answered

picking up data file in each iteration

"so how can automatically pick file in every itteration inside for loop ?" Following the outlines given in the MATLAB documenat...

picking up data file in each iteration

"so how can automatically pick file in every itteration inside for loop ?" Following the outlines given in the MATLAB documenat...

12 días ago | 0

| accepted

Answered

How to reshape a square matrix diagonally to a vector?

>> A = [0,1,0;1,1,1;1,1,0] A = 0 1 0 1 1 1 1 1 0 >> V = 1:sum(size(A))-1; >> W = fi...

How to reshape a square matrix diagonally to a vector?

>> A = [0,1,0;1,1,1;1,1,0] A = 0 1 0 1 1 1 1 1 0 >> V = 1:sum(size(A))-1; >> W = fi...

12 días ago | 2

| accepted

Answered

What is defined as an integer type, when calling validateattributes?

Lets read the validateattributes documentation, and see what it says. All of its calling syntaxes start with the exactly same t...

What is defined as an integer type, when calling validateattributes?

Lets read the validateattributes documentation, and see what it says. All of its calling syntaxes start with the exactly same t...

12 días ago | 2

| accepted

Answered

Index exceeds array bounds, when call a function with struct parameter

A structure is an array. It can be empty, or scalar, or have size 2x3, or whatever size you want, just like any otther type of a...

Index exceeds array bounds, when call a function with struct parameter

A structure is an array. It can be empty, or scalar, or have size 2x3, or whatever size you want, just like any otther type of a...

12 días ago | 0

| accepted

Answered

Regexp with a list of keywords

Using a simple lookaround assertion: https://www.mathworks.com/help/matlab/matlab_prog/regular-expressions.html#brchk1t >> key...

Regexp with a list of keywords

Using a simple lookaround assertion: https://www.mathworks.com/help/matlab/matlab_prog/regular-expressions.html#brchk1t >> key...

12 días ago | 0

| accepted

Answered

GUI calls function1 which has a uitable and callback...

The guidata documentation states that its first input argument must be a handle to any graphics object in your GUI. What is its ...

GUI calls function1 which has a uitable and callback...

The guidata documentation states that its first input argument must be a handle to any graphics object in your GUI. What is its ...

12 días ago | 0

Answered

Time in hr min sec to seconds

>> str = '152605'; >> vec = sscanf(str,'%2d'); >> out = [60*60,60,1]*vec out = 55565

Time in hr min sec to seconds

>> str = '152605'; >> vec = sscanf(str,'%2d'); >> out = [60*60,60,1]*vec out = 55565

12 días ago | 1

Answered

creating matrix out of another matrix

out = reshape(results(:,4),13,8).'; out(:,14) = 4; % if you want an 8x14 matrix

creating matrix out of another matrix

out = reshape(results(:,4),13,8).'; out(:,14) = 4; % if you want an 8x14 matrix

13 días ago | 1

Answered

How to assign input given by user via inpuutdlg command to variables

Just use indexing: out = inputdlg(...); somevar = out{1}; othervar = out{2}; ... https://www.mathworks.com/help/matlab/mat...

How to assign input given by user via inpuutdlg command to variables

Just use indexing: out = inputdlg(...); somevar = out{1}; othervar = out{2}; ... https://www.mathworks.com/help/matlab/mat...

13 días ago | 0

| accepted

Answered

Array indices must be positive integers or logical values.

Check your indexing: >> colum = 128; >> dtn = 129; >> colum-dtn+1 ans = 0 MATLAB indexing start at 1.

Array indices must be positive integers or logical values.

Check your indexing: >> colum = 128; >> dtn = 129; >> colum-dtn+1 ans = 0 MATLAB indexing start at 1.

13 días ago | 0

Answered

How to find the full file path with only a folder?

Until MATLAB has an inbuilt function for this, the general solution is to download one of these: https://www.mathworks.com/matl...

How to find the full file path with only a folder?

Until MATLAB has an inbuilt function for this, the general solution is to download one of these: https://www.mathworks.com/matl...

13 días ago | 0

Answered

How do I access a specific directory so I can then retrieve images in that directory with a specific file extension?

D = 'relative or absolute path to the specific directory'; S = dir(fullfile(D,'*.png')); C = {S.name} % output cell array

How do I access a specific directory so I can then retrieve images in that directory with a specific file extension?

D = 'relative or absolute path to the specific directory'; S = dir(fullfile(D,'*.png')); C = {S.name} % output cell array

13 días ago | 0

Answered

Variable highlighting isn't working

"I can't seem to get variables to be highlighted in the editor." MATLAB automatically highlights all reachable instances of a v...

Variable highlighting isn't working

"I can't seem to get variables to be highlighted in the editor." MATLAB automatically highlights all reachable instances of a v...

13 días ago | 1

| accepted

Answered

How can I concatenate multiple doubles within one cell into one double with the same length?

Try using a comma-separated list: cat(2,SubjectData{1}.movementTime)

How can I concatenate multiple doubles within one cell into one double with the same length?

Try using a comma-separated list: cat(2,SubjectData{1}.movementTime)

14 días ago | 0

| accepted

Answered

How to separate a portion of filename from a file

Simpler: >> str = 'scrubbed.MOD_D3_AOD_550.20020112.nc'; >> out = regexp(str,'\d{8}','match','once') out = 20020112

How to separate a portion of filename from a file

Simpler: >> str = 'scrubbed.MOD_D3_AOD_550.20020112.nc'; >> out = regexp(str,'\d{8}','match','once') out = 20020112

14 días ago | 1

Answered

Only add to empty elements in an array

>> d = cat(3,a,b,c); >> sum(d.*(cumsum(d~=0,3)==1),3) ans = 1 2 3 4 5 6 7 8 9

Only add to empty elements in an array

>> d = cat(3,a,b,c); >> sum(d.*(cumsum(d~=0,3)==1),3) ans = 1 2 3 4 5 6 7 8 9

14 días ago | 0

| accepted

Answered

Function returning ans instead of three outputs

You need to call the function with three output arguments, e.g.: inp = [...]; % your input array [RR,GG,BB] = MostDistantPixel...

Function returning ans instead of three outputs

You need to call the function with three output arguments, e.g.: inp = [...]; % your input array [RR,GG,BB] = MostDistantPixel...

14 días ago | 1

| accepted

Answered

Creating a stacked bar plot

The bar documentation states "If y is a matrix, then bar groups the bars according to the rows in y", so you need to translate y...

Creating a stacked bar plot

The bar documentation states "If y is a matrix, then bar groups the bars according to the rows in y", so you need to translate y...

15 días ago | 0

| accepted

Answered

Converting columns in a matrix to percentage

>> M = [48,40,35,52,38,11,64,39,26;50,35,37,55,43,24,54,25,26;33,27,36,28,26,27,39,27,16;40,29,40,51,29,24,47,32,29;66,37,38,51,...

Converting columns in a matrix to percentage

>> M = [48,40,35,52,38,11,64,39,26;50,35,37,55,43,24,54,25,26;33,27,36,28,26,27,39,27,16;40,29,40,51,29,24,47,32,29;66,37,38,51,...

15 días ago | 0

| accepted

Answered

How can I create cell arrays that are in sequential order?

Two simple solutions: add sufficient leading zeros to all of the numbers (then a character sort will give the correct order). T...

How can I create cell arrays that are in sequential order?

Two simple solutions: add sufficient leading zeros to all of the numbers (then a character sort will give the correct order). T...

15 días ago | 1

Answered

Read a specified list of images given the filename and the directory the files are in

D = "path of the directory where the images are saved"; S = ["string array","of","the image filenames"]; N = numel(S); C = ce...

Read a specified list of images given the filename and the directory the files are in

D = "path of the directory where the images are saved"; S = ["string array","of","the image filenames"]; N = numel(S); C = ce...

15 días ago | 0

Answered

How to index tables in a struct? (to call each field from App Designer)

You need to loop over the fieldnames: app.data = load('workspace.mat'); C = fieldnames(app.data); for k = 1:numel(C) T =...

How to index tables in a struct? (to call each field from App Designer)

You need to loop over the fieldnames: app.data = load('workspace.mat'); C = fieldnames(app.data); for k = 1:numel(C) T =...

16 días ago | 0

| accepted

Answered

How to index so end+1 goes to the beginning of an array

>> V = 1:4; >> V(1+mod((end+1)-1,end)) ans = 1 >> V(1+mod((end+0)-1,end)) ans = 4 >> V(1+mod((end-1)-1,end)) a...

How to index so end+1 goes to the beginning of an array

>> V = 1:4; >> V(1+mod((end+1)-1,end)) ans = 1 >> V(1+mod((end+0)-1,end)) ans = 4 >> V(1+mod((end-1)-1,end)) a...

16 días ago | 0

| accepted

Answered

Is it possible to organize variables shown in workspace?

"At the end of simulation are variables of two scripts are shown in workspace alphabetically. Is it possible to sort them by scr...

Is it possible to organize variables shown in workspace?

"At the end of simulation are variables of two scripts are shown in workspace alphabetically. Is it possible to sort them by scr...

17 días ago | 0