Answered
Finding series of values within array
There is no need to use |find| when logical indexing is much faster. The following code extracts _all_ values from |X| where th...

11 years ago | 0

Answered
What does output describe in fminbnd?
Why not start by reading the documentation? You can locate the documentation in 0.5 seconds using your favorite internet search ...

11 years ago | 0

Answered
How to make dynamic variable names (A1, A2, ..., An) with "for" loop? Using "eval" "num2str"?
https://www.mathworks.com/help/matlab/matlab_prog/string-evaluation.html https://www.mathworks.com/matlabcentral/answers/304528...

11 years ago | 8

| accepted

Answered
Preallocating matrix with a numeric trend
Here is a reasonably efficient solution: U = 40:5:70; % values of Mx1 V = 45:5:140; % values of Mx2 M = numel(U); ...

11 years ago | 0

| accepted

Answered
Why does my matlab function produce result more than I expect?
Your function |Testing| has two _outputs_, and when you call the function the first output is displayed by default, unless you s...

11 years ago | 1

Answered
Evaluate a changing expression in loop
It all depends on what you mean by _"random"_: surely there must be some limit to the power or coefficient, and a limit to the n...

11 years ago | 0

| accepted

Answered
Size of displayed figure is different from position property
Check the following <http://www.mathworks.com/help/matlab/ref/figure-properties.html figure properties>: * <http://www.mathwo...

11 years ago | 0

Answered
How to create structure file?
Read this and try some of its examples: <http://www.mathworks.com/help/matlab/matlab_prog/access-multiple-elements-of-a-nonsc...

11 years ago | 0

Answered
How to delete [ ] from an array
You can using indexing to remove those cells from the cell array: A(cellfun('isempty',A)) = []

11 years ago | 2

| accepted

Answered
Defining value range in colormap manually
You just need to supply the fourth option to <http://www.mathworks.com/help/matlab/ref/scatter.html |scatter|>, which maps the v...

11 years ago | 1

| accepted

Answered
how to display {m,n} with its answer for example {1,2}=2?
There is no need for any loop, this is simpler and faster: >> V = [2,3,5,6,3,7,3,2,4,5]; >> X = [nchoosek(1:5,2),V(:)]; ...

11 years ago | 0

Answered
Binary data in Logical associated with coordinates
>> X = randi(2,5)-1; >> [R,C] = find(X); >> csvwrite('temp2.txt',[R,C]) produces this file (with the coordinates of t...

11 years ago | 0

| accepted

Answered
Binary data in Logical Array into a text file
>> X = randi(2,5)-1; >> csvwrite('temp.txt',X) creates a text file containing this: 1,1,0,0,1 1,1,0,1,1 1,0,0...

11 years ago | 0

| accepted

Answered
Hi, I am new to the matlab software. When I run the matlab script which I got from my collegue , I am getting the following error.
|pop_loadset| is not an inbuilt MATLAB file, but it is a third-party file (i.e. not written by TMW/MATLAB). You need to obtain a...

11 years ago | 0

Answered
hi, i want to find in a binary random matrice position of columns full of zeros (a column of zeros)..
You can use |all| and |find| to locate columns containing only zeros: >> X = randi(2,3,23)-1 X = 0 0 0 0 1...

11 years ago | 0

| accepted

Answered
How to find prefix in a sting
Use indexing: >> str = '0234567'; >> str(1) ans = 0

11 years ago | 1

| accepted

Answered
Error: Not enough input arguments (using function fminsearch)
The error message tells us that your function requires some arguments, but that you are not providing these arguments when you c...

11 years ago | 0

Answered
Several Operations Within a Matrix Matlab
data=[0 1 0 0 1 2 1 200 2 3 1 300 3 4 1 400 4 5 2 ...

11 years ago | 0

| accepted

Answered
Is fmincon open source
If you can open the file then you can probably read the copyright, which looks something like this: % Copyright 1990-2010...

11 years ago | 0

Answered
how to identify the particular element and its position in matlab?
>> find(f(1:28)==1) ans = 1 6 11 14 17 23 25 You also might like to do the introductory tutor...

11 years ago | 0

Answered
Labelling matrix dynamically regardless of its size
>> M = [5,5,3;3,1,3;7,6,4]; >> C = num2cell(M); >> C(2:end+1,2:end+1) = C; >> C{1,1} = ''; >> C(2:end,1) = strcat(...

11 years ago | 0

| accepted

Answered
Combining fields of a struct
[stocks.Close] It really is that simple. Here is a working example: >> A(1).x = rand(4,1); >> A(2).x = rand(4,1); ...

11 years ago | 1

Answered
How to create file names in certain format?
You can use <http://www.mathworks.com/help/matlab/ref/sprintf.html |sprintf|> and specify the required length and leading zeros:...

11 years ago | 0

| accepted

Answered
Why isn't strfind written to return a value in all cases?
What you are proposing breaks a basic property of |strfind| (and |find|, etc): the number of elements in the output is equal to ...

11 years ago | 0

Answered
Adding a number to a vector depending on a different vector
Use a simple multiplication: B + A*128 or perhaps logical indexing: B(A==1) = B(A==1)+128

11 years ago | 0

| accepted

Answered
How to publish a script including many figures but not opening them on the screen
Here are a few ideas to make managing figures easier: * Instead of multiple figures just create one figure, and then update a...

11 years ago | 0

Answered
In this forum: I have written a private message to someone on fileexchange, how can I see if he has answered?
There isn't any "inbox", "messages" or anything similar here. When you send a message to a contributor it simply sends them an e...

11 years ago | 3

| accepted

Answered
What format of data files is adequate to reduce the processing time?
The <https://en.wikipedia.org/wiki/ActiveX ActiveX> framework allows applications to access and control Microsoft applications. ...

11 years ago | 0

| accepted

Answered
saving values of one array into another array using for loop statement
Try this: % load the data: matc = load('C:\Users\Naseeb\Desktop\centroids.mat'); matp = load('C:\Users\Naseeb\Desktop...

11 years ago | 1

| accepted

Answered
Illegal use of reserved keyword "else".
This code is a good example of why *badly formatted code* causes so many problems. Why do beginners avoid using the *inbuilt edi...

11 years ago | 2

| accepted

Load more