Answered

Sort() function return wrong values

You are not assigning the sorted matrix to anything. You need to assign it to a variable, e.g.: minCell = minCell(s, :);

Sort() function return wrong values

You are not assigning the sorted matrix to anything. You need to assign it to a variable, e.g.: minCell = minCell(s, :);

7 Tage ago | 0

| accepted

Answered

Find index of element closest to other index

>> B1 = [0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1] B1 = 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 >> B2 = [1,1,...

Find index of element closest to other index

>> B1 = [0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1] B1 = 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 >> B2 = [1,1,...

7 Tage ago | 0

| accepted

Answered

How to read multiple image directory with for loop

Rather than fragile string concatenation and ungainly constructs involving int2str or num2str, the neat and efficient MATLAB app...

How to read multiple image directory with for loop

Rather than fragile string concatenation and ungainly constructs involving int2str or num2str, the neat and efficient MATLAB app...

7 Tage ago | 1

Answered

how to get the memory address of variable in matlab

Undocumented feature, has been around for many versions: format debug Examples of its usage: https://www.mathworks.com/matlab...

how to get the memory address of variable in matlab

Undocumented feature, has been around for many versions: format debug Examples of its usage: https://www.mathworks.com/matlab...

7 Tage ago | 0

Answered

How to check if a element of a struct is empty?

fun = @(s) all(structfun(@isempty,s)); % check the fields of a scalar structure. idx = arrayfun(fun,Res_All_Meas); % indices of...

How to check if a element of a struct is empty?

fun = @(s) all(structfun(@isempty,s)); % check the fields of a scalar structure. idx = arrayfun(fun,Res_All_Meas); % indices of...

7 Tage ago | 0

Answered

How to rename an image after processing with different parameters

The cause of the problem is that your inner loop repeatedly processes the same string of the cell array Outputs. So you just kee...

How to rename an image after processing with different parameters

The cause of the problem is that your inner loop repeatedly processes the same string of the cell array Outputs. So you just kee...

7 Tage ago | 0

| accepted

Answered

how to calculate mean of submatrices in a large matrix and print out a new matrix

>> M = [11,12,13,14;21,22,23,24;31,32,33,34;41,42,43,44;51,52,53,54;61,62,63,64] M = 11 12 13 14 21 22 23 2...

how to calculate mean of submatrices in a large matrix and print out a new matrix

>> M = [11,12,13,14;21,22,23,24;31,32,33,34;41,42,43,44;51,52,53,54;61,62,63,64] M = 11 12 13 14 21 22 23 2...

7 Tage ago | 0

| accepted

Answered

How to effectively check a list of variables for existence and then check "isvector"

"The data are loaded from "mat" files, some may exist but some may not." Once those .mat files are already loaded directly into...

How to effectively check a list of variables for existence and then check "isvector"

"The data are loaded from "mat" files, some may exist but some may not." Once those .mat files are already loaded directly into...

7 Tage ago | 0

Answered

Function is not working

The basic problem is that you keep repeating the same indexing, e.g.: resp = responses(targets==target); .. err = resp(target...

Function is not working

The basic problem is that you keep repeating the same indexing, e.g.: resp = responses(targets==target); .. err = resp(target...

8 Tage ago | 0

Answered

Extracting Data to a workspace

The MATLAB approach: >> [X,Y] = meshgrid(0:3,0:2); >> A = X+Y; >> M = [X(:),Y(:),A(:)] M = 0 0 0 0 1 1 0...

Extracting Data to a workspace

The MATLAB approach: >> [X,Y] = meshgrid(0:3,0:2); >> A = X+Y; >> M = [X(:),Y(:),A(:)] M = 0 0 0 0 1 1 0...

8 Tage ago | 0

| accepted

Answered

Creating a Matrix from a nesting For loop

The MATLAB approach: >> [Xm,Ym] = meshgrid(1:25,1:25); >> Zm = Xm.*Ym; >> surf(Xm,Ym,Zm) Giving:

Creating a Matrix from a nesting For loop

The MATLAB approach: >> [Xm,Ym] = meshgrid(1:25,1:25); >> Zm = Xm.*Ym; >> surf(Xm,Ym,Zm) Giving:

9 Tage ago | 0

| accepted

Answered

Problem with plotting vector fields

"also the figure I get comes out to be emtpy" You need to use array operations, not matrix operations: >> [X,Y] = meshgrid(2:1...

Problem with plotting vector fields

"also the figure I get comes out to be emtpy" You need to use array operations, not matrix operations: >> [X,Y] = meshgrid(2:1...

9 Tage ago | 0

| accepted

Answered

Passing Structure Array of Parameters into Boundary Condition Function for PDEPE

You need to parameterize the function: https://www.mathworks.com/help/matlab/math/parameterizing-functions.html Usually the si...

Passing Structure Array of Parameters into Boundary Condition Function for PDEPE

You need to parameterize the function: https://www.mathworks.com/help/matlab/math/parameterizing-functions.html Usually the si...

9 Tage ago | 0

| accepted

Answered

Not enough input arguments

There are two main bugs that we need to fix: define the correct function outputs. call the function with input and output argu...

Not enough input arguments

There are two main bugs that we need to fix: define the correct function outputs. call the function with input and output argu...

9 Tage ago | 0

Answered

How to modify field any levels deep in a structure with a string

"i cant break the string into its fields and use something like app.(str1).(str2).str(3)..." You cannot use dynamic fieldnames ...

How to modify field any levels deep in a structure with a string

"i cant break the string into its fields and use something like app.(str1).(str2).str(3)..." You cannot use dynamic fieldnames ...

10 Tage ago | 0

| accepted

Answered

check if an array is equispaced

>> v = [1,2,3,4,5,6,7]; >> x = ~any(diff(v,2)) x = 1 >> v = [1,2,4,4.5,7]; >> x = ~any(diff(v,2)) x = 0

check if an array is equispaced

>> v = [1,2,3,4,5,6,7]; >> x = ~any(diff(v,2)) x = 1 >> v = [1,2,4,4.5,7]; >> x = ~any(diff(v,2)) x = 0

10 Tage ago | 1

Answered

Regular expressions: extracting data after certain keywords

For such a large file I would get textscan to directly import the numeric data. With a few simple file commands you can also aut...

Regular expressions: extracting data after certain keywords

For such a large file I would get textscan to directly import the numeric data. With a few simple file commands you can also aut...

10 Tage ago | 0

| accepted

Answered

Executing the body of IF statement.

Solution: the logic is incorrect: ~ii==attack should be ii~=attack Explanation: the code ~ii==attack following the rules o...

Executing the body of IF statement.

Solution: the logic is incorrect: ~ii==attack should be ii~=attack Explanation: the code ~ii==attack following the rules o...

10 Tage ago | 1

| accepted

Answered

How to define a struct array with length more than one and assign values to one of the strucy array?

>> A = [1,0.2,3,0.4,5,6]; >> X = [1,3,4,6]; % "I only want to save these four values" >> Ac = num2cell(A); >> Bc = num2cell(A...

How to define a struct array with length more than one and assign values to one of the strucy array?

>> A = [1,0.2,3,0.4,5,6]; >> X = [1,3,4,6]; % "I only want to save these four values" >> Ac = num2cell(A); >> Bc = num2cell(A...

10 Tage ago | 0

| accepted

Answered

store a huge number of rows in a in a matrix (out of memory error)

"I searched through the internet and become familiar with tall matrix but as far as I understand that matrix is just read-only.....

store a huge number of rows in a in a matrix (out of memory error)

"I searched through the internet and become familiar with tall matrix but as far as I understand that matrix is just read-only.....

10 Tage ago | 0

Answered

substitute of persistent command

You could use nested functions for this: function main() sij = []; Tj = [] esj = []; ej = []; .. etc. [yo_new,ypo_new] ...

substitute of persistent command

You could use nested functions for this: function main() sij = []; Tj = [] esj = []; ej = []; .. etc. [yo_new,ypo_new] ...

11 Tage ago | 1

Answered

How do I preallocate this variable so that I can remove my warning and test whether my while loops are infinite or whether my code is just computing really slowly?

result = nan(16,2); % preallocate for ...

How do I preallocate this variable so that I can remove my warning and test whether my while loops are infinite or whether my code is just computing really slowly?

result = nan(16,2); % preallocate for ...

13 Tage ago | 0

| accepted

Answered

Writing result of script (ran in a loop) into vector

Something does not make much sense: given NumOfRuns = 3, why does results have 26 columns? I suspect that the script also conta...

Writing result of script (ran in a loop) into vector

Something does not make much sense: given NumOfRuns = 3, why does results have 26 columns? I suspect that the script also conta...

13 Tage ago | 0

Answered

Loop over an array or list of vectors

While it is possible to loop over array elements directly, in practice it is usually much more convenient and versatile to loop ...

Loop over an array or list of vectors

While it is possible to loop over array elements directly, in practice it is usually much more convenient and versatile to loop ...

13 Tage ago | 2

| accepted

Answered

indexing a field in a structure

Your indexing is not correct. If s(11).structure has exactly 270 elements, then all you need is this: out = [s(11).structure.Me...

indexing a field in a structure

Your indexing is not correct. If s(11).structure has exactly 270 elements, then all you need is this: out = [s(11).structure.Me...

13 Tage ago | 0

| accepted

Answered

Should be easy but I keep getting errors. I want to input the array through a function that I already have generated through equations then plot it.

As the ode45 documentation explains here (with examples): https://www.mathworks.com/help/matlab/ref/ode45.html#bu3uhuk the cor...

Should be easy but I keep getting errors. I want to input the array through a function that I already have generated through equations then plot it.

As the ode45 documentation explains here (with examples): https://www.mathworks.com/help/matlab/ref/ode45.html#bu3uhuk the cor...

14 Tage ago | 0

Answered

2d array and 1d array

N = 3; DecodeData = nan(N,55); for k = 1:N TempStorage = ... whatever defines your 1x55 vector DecodeData(k,:) = Tem...

2d array and 1d array

N = 3; DecodeData = nan(N,55); for k = 1:N TempStorage = ... whatever defines your 1x55 vector DecodeData(k,:) = Tem...

14 Tage ago | 0

| accepted

Answered

Combining two different size variables into one matrix

The simplest solution is to download this: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat and then all you ...

Combining two different size variables into one matrix

The simplest solution is to download this: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat and then all you ...

14 Tage ago | 0

| accepted

Answered

Save Structure to .mat-file in dialog via GUI

S = .. your big structure [F,P] = uiputfile('*.mat'); save(fullfile(P,F),'-struct','S') % if S is scalar save(fullfile(P,F),'...

Save Structure to .mat-file in dialog via GUI

S = .. your big structure [F,P] = uiputfile('*.mat'); save(fullfile(P,F),'-struct','S') % if S is scalar save(fullfile(P,F),'...

14 Tage ago | 0

| accepted