Answered
Replace specific values in a matrix with zeros
In one line: >> A = [... 35 1 6 26 19 24 3 32 7 21 23 25 31 9 2 ...

9 years ago | 1

| accepted

Answered
Problem with the ceil-operator
There is nothing wrong with |ceil|, and there is no _"weird behavior"_. You need to learn that *computers do not have infinit...

9 years ago | 2

Answered
How do I make a for loop and use logical operators
Counting the non-matches is a creative solution to the problem, and it simply requires counting down from the total number of el...

9 years ago | 1

| accepted

Answered
Weighted matrix to edge list
One way based around |ndgrid|: >> M = [10 1 9; 1 5 4; 2 1 5]; >> N = M.'; >> S = size(N); >> [R,C] = ndgrid(1:S(1)...

9 years ago | 0

| accepted

Answered
Reshape cell array into a matrix
Assuming that those should be numeric vectors: a{1} = [1 2 3 4 5]; a{2} = [2 2 4 5]; a{3} = [8 2]; a{4} = [8 2 9 9...

9 years ago | 1

| accepted

Answered
Outputting multiple matrix of a function within a for loop?
*Solution:* The problem is caused by the transpose operation: for n = (0:size(T)-1)' ^ this causes ...

9 years ago | 0

Answered
Is it possible to reshape a vector into 3D matrix
Use <https://www.mathworks.com/help/matlab/ref/reshape.html |reshape|>: >> V = rand(1,43264); >> A = reshape(V,13,13,256...

9 years ago | 0

Answered
Assign an array of structs to a cell
In your example code you need to change the indexing into the cell array from |i| to |k|: carray{k} = results;

9 years ago | 0

| accepted

Answered
Saving names of variables with concatenate
Your approach of storing all of the data in lots of separate variables with meta-data in the variable names is making your life ...

9 years ago | 0

| accepted

Answered
Image Graphs How to use it
As its help clearly states <https://www.mathworks.com/help/matlab/ref/graph.html |graph|> was introduced in R2015b. Solution ...

9 years ago | 0

| accepted

Answered
Sum the numbers of a range 1 + 1/2 + 1/3 + ... + 1/n with a while-loop.
Some points about your code: * Do NOT name any variable |sum|*, because |sum| is a very important inbuilt function that will ...

9 years ago | 0

Answered
Get Values from other m.file via dropdown
One easy way would be to store the data in a structure: S.C25.Rm = 500; S.C25.Rp = 600; S.C35.Rm = 800; S.C35.Rp =...

9 years ago | 0

| accepted

Answered
Adding random data to left and right of each element in a matrix
M = [ 1 2 3 4 5 6 7 8 9 10 11 12]; E = [ ...

9 years ago | 1

| accepted

Answered
Extract numbers from an integer
If you do not want to convert to string and can only perform numeric operations, then you can use |mod| and division in a loop: ...

9 years ago | 0

Answered
Question about extracting a structure field using eval
*Do NOT use |eval| for such trivial code.* This way of accessing structure fields has been *obsolete* for more than ten years, a...

9 years ago | 1

| accepted

Answered
Using matrixes in functions
Much simpler would be to just use |min| to pick the output values. Then all you need is this: function [torque,mat] = compu...

9 years ago | 2

| accepted

Answered
Indexing Vector of Variables
That is what the histogram functions do very easily and efficiently: <https://www.mathworks.com/help/matlab/ref/histc.html> ...

9 years ago | 0

| accepted

Answered
How to change length of a matrix and delete entries?
It is not clear if you want to select the columns by index, or by detecting if any/all of the values are zeros. Here are both so...

9 years ago | 1

| accepted

Answered
Choosing a specific data from a structure
Alpha = FileData.(Name2).Vectors; <https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variable...

9 years ago | 0

| accepted

Answered
Evaluation of function handle matrix erases values
_"I receive the vector [1;1;0] instead of [1;0;1;0] which I would expect"_ Your function f = @(x,y) [x;0] concatenate...

9 years ago | 1

Answered
How to "filter" an N-D array with matrix indexing?
One efficient way to achieve this for any ND array is to call <https://www.mathworks.com/help/matlab/ref/subsref.html |subsref|>...

9 years ago | 0

| accepted

Answered
Form a Cumulative sum matrix
>> S = randi(9,10,1300); >> R = randi(9,10,1300); >> Z = cumsum(S,1)+2*cumsum(R,1)-R; >> Z(10,:) = Z(10,:)+R(10,:); ...

9 years ago | 0

| accepted

Answered
Functions as function inputs with specified inputs
You need to pass the <https://www.mathworks.com/help/matlab/function-handles.html function handle>, because what you are doing n...

9 years ago | 1

| accepted

Answered
How can I store the output from a function to the workspace ?
The function |tsp_ga| returns a structure with lots of values in it. |minDist| is one of those values: S = tsp_ga(...) S...

9 years ago | 0

| accepted

Answered
How to solve "Not enough input arguments" error?
You either need x = fsolve(@curv_,x0) or x = fsolve(fun,x0) Why? Because your code _calls_ the function, rather ...

9 years ago | 0

| accepted

Answered
Finding unique cell elements
We can take advantage of the fact that |unique| accepts a cell array of char vectors, which means we can convert those numeric v...

9 years ago | 1

| accepted

Answered
Merging elements in cell array using common value
Here is one solution using <https://www.mathworks.com/help/matlab/ref/unique.html |unique|> and <https://www.mathworks.com/help/...

9 years ago | 0

| accepted

Answered
Adding numbers in a matrix to equal zero
This is MATLAB, so there is no need to write ugly code with lots of loops and ifs when it is so much simpler and neater to opera...

9 years ago | 1

| accepted

Answered
How do I use the tag/name/handle of a axes rather than gca
While you could use the tag to locate and work with graphics obejcts, actually the simplest and most reliable way to access grap...

9 years ago | 0

Answered
Search a complex structure for all instances of a variable
You can easily write your own simple recursive function to parse the tree structure, detect and return any field of your choice ...

9 years ago | 0

Load more