Answered
Plotting exponential curves with random numbers.
Here is something to get you started x = linspace(-10,10,100) ; hold on % help! for k = 1:5, B = 0.15 + (0...

12 years ago | 0

Answered
How to plot number of box plots in a single figure? each box plot is a verctor of variable length.
Here is an example. % Given two column vectors with different lengths V1 = 5 + 10 * randn(7,1) ; V2 = 10 ...

12 years ago | 0

Answered
How to determine samplenumber for fixed distance-intervals?
For examples, I prefer integers, so I upscaled everything by a factor 10. % your data M = [0 1 4 6 8 10 12 14 16 17 18 1...

12 years ago | 0

| accepted

Answered
Unsure of how to use and understand rand function
It is always insightful to look at a smaller example: A = [ 4 2 3 1 ; 5 4 2 3 ; 6 7 8 9 ; 1 4 2 5] % just 2-by-2 instead of...

12 years ago | 0

Answered
IF / ELSE Usage within For loop for Specific Iteration Only
As a follow-up, if you only need to perform the statements within a for-loop when the iterator takes specific values, you can ch...

12 years ago | 1

Answered
Do while loop in Matlab
A do-while loop in disguise: while true % statements here % if ~WhileCondition, break ; end end or

12 years ago | 22

Answered
How to replace element matrix with the other matrix?
Even simpler: % example data A = 99 * ones(2,2) B = -1 * ones(6,8) % engine szA = size(A) i0 = (size(B)-sz...

12 years ago | 0

Answered
How to replace element matrix with the other matrix?
To replace the central portion of B with A try this % example data A = 2 * ones(2,2) B = -3 * ones(6,8) % eng...

12 years ago | 0

Answered
Including comments in a .mat file?
Another option might be to use a structure: A.values = [21 22 35] A.label = 'temperature' A.unit = 'degrees Cels...

12 years ago | 1

Answered
Fast matrix multiplication in loop
Two options: 1. *pre-allocate* C to avoid memory allocation in each iteration C = zeros(N, ..) % pre-allocation for ...

12 years ago | 0

Answered
i want all the combinations for [abc]...like abc, ab, ac, bc, a, b, c. can anyone help..Plz...
Take a look at my NCHOOSE function on the File Exchange as it does exactly what you're after. S = nchoose('abc') % S = {...

12 years ago | 3

Answered
How to replace element matrix with the other matrix?
I suggest that you give *a smaller example of A and B* and the required output.

12 years ago | 0

Answered
Help with linear fit
Here's how: tf = x > x1 & x < x2 % true for x1 < x < x2 p = polyfit(x(tf), y(tf),1) % fit on selection

12 years ago | 0

Answered
Finding Consecutive True Values in a Vector
Hide the loops ;-) input = [1 0 1 1 0 0 1 1 1 0 1 0 1 1 1 1 0] [~,~,C] = logicalfind(input,1) ; C = cellfun(@cums...

12 years ago | 0

Answered
use of conditional statement
Here is an example to obtain low intensities. It is often handy to keep the original format and set the elements you are not int...

12 years ago | 0

| accepted

Answered
discrete value to binary value
what are discrete values? integers in decimal notation? help dec2bin dec2bin(9)

12 years ago | 0

| accepted

Answered
Out of memory error in combination combnk
*Questions* # Do you need them all 1.2652e14 at the same time? (Impossible!) # Do you need only a random fraction of these? ...

12 years ago | 1

Answered
Adding noise with certain standard deviation to uncorrupted data
In addition to Wayne's suggestion you can sample noise from any distribution with unknown parameters and set the standard deviat...

12 years ago | 2

Answered
Import excel file with comma for decimal and dates
In excel and/or in Windows System settings (i do not know where) change the settings of the decimal notation to dot and to the r...

12 years ago | 1

Answered
please help me sort this out
When column number does matter: % A : a N-by-M array % B : a 1-by-N row vector [~, ii] = max(sum(bsxfun(@eq,A,B),2)) ...

12 years ago | 1

Answered
Why the preallocated matrix perform slower in the case below?
You are not doing the same thing, as it takes time to evaluate the indices into ZZn, as well as temporary memory to store them. ...

12 years ago | 0

Answered
Random Binary Sequence Generator
Here are two suggestions: % with 0 <= P <=1 RBS = rand(1,N) < P % will give roughly a proportion of P ones among ...

12 years ago | 1

Answered
concatenate each element of two arrays
A=['a' 'b' 'c'] B = ['1' '2'] C = allcomb(A,B) ALLCOMB can be found here: http://www.mathworks.com/matlabcentral/f...

12 years ago | 1

Answered
How i use a variable name to do a fid=fopen?
Create a function m-file, where you can use a variable. function MyProgram (MyInputFile) % MYPROGRAM (FILE) opens the ...

12 years ago | 0

Answered
Finding values in an Array
Apply some arithmetic: Subject = [126 156 1992 203 186 10 100 100000] Group = fix(Subject ./ (10.^floor(log10(Subject)...

12 years ago | 1

| accepted

Submitted


LOGICALFIND
Find occurrences of consecutive non-zeros in a vector (v1.0, jan 2014)

12 years ago | 1 download |

5.0 / 5

Answered
Can you help me solving that?
No need for an explicit loop as you can exploit the power of MatLab with *BSXFUN*. % example data A =[1 2 3 4 5 6 7 ...

12 years ago | 0

Answered
Matrix Multiplications (Altar Output Matrix Size)
Your question is a little confusing. Do you intend to do element-by-element multiplication or matrix multiplication? Assuming...

12 years ago | 0

Answered
change values in a matrix
Another problem needs another solution: a = [0.1234 -1.9876 -2.0001 22.9999] b = a % work on a copy q = ...

12 years ago | 0

| accepted

Answered
How does command STEM work for complex numbers?
STEM uses PLOT to make its lines. The documentation of PLOT is clear on complex numbers: _PLOT(Y) plots the columns of Y vers...

12 years ago | 0

Load more