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...

7 days 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...

7 days 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 ...

8 days 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

8 days 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...

8 days 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...

8 days 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...

8 days 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.....

8 days 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] ...

9 days 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 ...

11 days 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...

11 days 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 ...

11 days 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...

11 days 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...

12 days 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...

12 days 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 ...

12 days 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),'...

12 days ago | 0

| accepted

Answered

Vertical concatenation of structure fields (compact form)

Your example concatenates horizontally because it is exactly equivalent to doing this: [structure(1).field,structure(2).field] ...

Vertical concatenation of structure fields (compact form)

Your example concatenates horizontally because it is exactly equivalent to doing this: [structure(1).field,structure(2).field] ...

12 days ago | 0

| accepted

Answered

How to store partially known datetimes

I don't believe that information can be encoded inside one datetime object, so you will have to use another object or variable t...

How to store partially known datetimes

I don't believe that information can be encoded inside one datetime object, so you will have to use another object or variable t...

12 days ago | 0

| accepted

Answered

How can I assign a value to variable using buttons?

I think writing your own GUI is a red herring. Unless it really is your goal to learn all about asynchronous code, callback func...

How can I assign a value to variable using buttons?

I think writing your own GUI is a red herring. Unless it really is your goal to learn all about asynchronous code, callback func...

13 days ago | 1

| accepted

Answered

Converting a Data Array into a Larger Array Given a Logical Array

>> idx = logical([1,0,1,0,1,0,0,0,1]); >> dat = [5,3,7,4]; >> out = zeros(size(idx)); % preallocate >> out(idx) = dat out = ...

Converting a Data Array into a Larger Array Given a Logical Array

>> idx = logical([1,0,1,0,1,0,0,0,1]); >> dat = [5,3,7,4]; >> out = zeros(size(idx)); % preallocate >> out(idx) = dat out = ...

13 days ago | 0

| accepted

Answered

30x-11= 30/x

Simple numeric solution: >> fun = @(x) 30*x - 11 - 30./x; >> x = fzero(fun,pi) x = 1.2000 Checking: >> 30*x-11 ans = ...

30x-11= 30/x

Simple numeric solution: >> fun = @(x) 30*x - 11 - 30./x; >> x = fzero(fun,pi) x = 1.2000 Checking: >> 30*x-11 ans = ...

13 days ago | 0

Answered

Make for loop and extract data from different tables within a structure.

You are confusing the field names with an index, but really you should just be using an index. Rather than awkward messing about...

Make for loop and extract data from different tables within a structure.

You are confusing the field names with an index, but really you should just be using an index. Rather than awkward messing about...

13 days ago | 0

| accepted

Answered

Ode Not enough input arguments.

As the error states, you are not calling the function nozzlesinglebobbgola with enough input arguments: nozzlesinglebobbgola(x,...

Ode Not enough input arguments.

As the error states, you are not calling the function nozzlesinglebobbgola with enough input arguments: nozzlesinglebobbgola(x,...

13 days ago | 0

| accepted

Answered

given cell array 'cell1', create new cell array 'cell2' with elements of cell1 containing string 'f' and ages >=30 && <=40

age = vertcat(cell1{2:end,3}); ix1 = age>=30 & age<=40; ix2 = strcmp('f',cell1(2:end,2)); cell2 = cell1([false;ix1&ix2],:) G...

given cell array 'cell1', create new cell array 'cell2' with elements of cell1 containing string 'f' and ages >=30 && <=40

age = vertcat(cell1{2:end,3}); ix1 = age>=30 & age<=40; ix2 = strcmp('f',cell1(2:end,2)); cell2 = cell1([false;ix1&ix2],:) G...

13 days ago | 0

| accepted

Answered

Using Dir command together with xlsread troubleshooting

Much simpler: D = 'C:\Users\erik.from\Documents\MATLAB\Event'; S = dir(fullfile(D,'*.xlsx')); for k = 1:numel(S); F = fu...

Using Dir command together with xlsread troubleshooting

Much simpler: D = 'C:\Users\erik.from\Documents\MATLAB\Event'; S = dir(fullfile(D,'*.xlsx')); for k = 1:numel(S); F = fu...

13 days ago | 0

| accepted

Answered

How to fix Incorrect Code

Those "functions" don't help, get rid of them: >> LDR1 = 1; >> LDR2 = 2; >> R1 = 3; >> V = 5; >> V1 = V*R1/(R1+LDR1) V1 = ...

How to fix Incorrect Code

Those "functions" don't help, get rid of them: >> LDR1 = 1; >> LDR2 = 2; >> R1 = 3; >> V = 5; >> V1 = V*R1/(R1+LDR1) V1 = ...

13 days ago | 0

Answered

How do I write a script that calculates and prints all values for N according to the following expressions and limits?

"How do I write a script that calculates and prints all values for N according to the following expressions and limits?" k = ...

How do I write a script that calculates and prints all values for N according to the following expressions and limits?

"How do I write a script that calculates and prints all values for N according to the following expressions and limits?" k = ...

14 days ago | 0

| accepted

Answered

How to use nested functions to build a code that compares inputs

The comparison needs to be inside the loop (not after the loop): function result = grader(funA, funB, varargin) result = true;...

How to use nested functions to build a code that compares inputs

The comparison needs to be inside the loop (not after the loop): function result = grader(funA, funB, varargin) result = true;...

14 days ago | 0

| accepted