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

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

6 years 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:

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

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

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

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

6 years 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

6 years ago | 1

Answered
Insert elements to cell array
g = g(:,[1,1:end]); g(:,1) = {M}

6 years ago | 0

| accepted

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

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

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

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

6 years 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] ...

6 years ago | 1

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

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

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

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

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

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

6 years 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),'...

6 years 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] ...

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

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

6 years 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 = ...

6 years 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 = ...

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

6 years 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,...

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

6 years ago | 0

| accepted

Load more