Answered
cannot find the error in my code
Your function |random_rayleigh| calls itself on this line: tota_samples=mean_noise_level/1.25*random_rayleigh(1,no_of_sampl...

11 years ago | 0

Answered
passing variable between callbacks
The documentation, which describes all ways to pass data between callbacks: <http://www.mathworks.com/help/matlab/creating_gu...

11 years ago | 2

| accepted

Answered
How to add a more element in an existing cell array in specific positions?
Note that |l| is not a good variable name, as it is too easy to confuse for other characters. Try this: >> C = {[498,1],...

11 years ago | 1

| accepted

Answered
remove the number at the end of the string in cell array
You can use <http://www.mathworks.com/help/matlab/ref/regexprep.html |regexprep|> for this: >> a = { 'Gain' ; 'Gain1' ; 'De...

11 years ago | 2

| accepted

Answered
Find common files in two directories
You could download my FEX submission natsortfiles, which sorts filenames taking into account any numeric values in the filenames...

11 years ago | 0

Answered
finding most common letter in a bunch of words
It is easy using <http://www.mathworks.com/help/matlab/ref/mode.html |mode|>: >> x={'abac';'abaca';'abacate';'abacay';'abac...

11 years ago | 1

| accepted

Answered
The for loop gives an odd number instead of 0?
<http://www.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html Floating point numbers> are how decimal values are...

11 years ago | 0

| accepted

Answered
Matrices with MathLAB..
The most useful thing you can learn about MATLAB is to *read the documentation*. This is because *the documentation* tells you h...

11 years ago | 0

Answered
concatenating the several matrices in a certain manner
>> s1=[0 0 1 1;1 1 0 0;1 1 0 0;0 0 1 1] s1 = 0 0 1 1 1 1 0 0 1 1 0 ...

11 years ago | 1

| accepted

Answered
multiplying a 1xM vector by a KxN matrix
Use |bsxfun|, |reshape|, and |permute|: >> V = [1,-1] V = 1 -1 >> S = [0,0,1,1; 1,1,0,0; 1,0,1,0; 0,1,0,1]...

11 years ago | 2

| accepted

Answered
removing elements of cell array
>> x = {'aa';'aal';'aalii';'aam';'aani';'aardvark';'aardwolf';'aaron'}; >> word = 'nanny'; >> x(numel(word)~=cellfun(@nu...

11 years ago | 1

Answered
Writing results to different files
This is such a common question that we have a very detailed description in the wiki page, complete with example code. It has als...

11 years ago | 2

Answered
Seperate One Matrix into two!!
If you generate all of the indices using |randperm|, then you can simply select the first half of those indices and the second h...

11 years ago | 1

| accepted

Answered
How to create a cell array with struct elements?
Rather than putting lots of separate structures into a cell array, you should consider simply using a <http://www.mathworks.com/...

11 years ago | 2

Answered
Multiple element storing in a row
Try concatenating those values into one numeric vector: >> ant = num2cell(1:10)' % fake data ant = [ 1] [...

11 years ago | 2

| accepted

Answered
spliting up a char array
One answer to your question is to use indexing: >> S = '2.1*3C' S = 2.1*3C >> T = S(1:3) T = 2.1 If you w...

11 years ago | 1

| accepted

Answered
how to i delete the rows in a cell
>> C = {[1,2];[];[3,4]} C = [1x2 double] [] [1x2 double] >> C(cellfun('isempty',C),:) = [] C = ...

11 years ago | 1

Answered
Adding elements to an array
new_x = [zeros(1,n-1),x]

11 years ago | 1

| accepted

Answered
Do I need symbolic math toolbox to graph a function such as f(x)=ln(x) or f(x, y)=y^2/x
There is no need for the symbolic toolbox for such simple functions. Try this: >> X = 0:0.1:3; >> Y = log(X); >> plot...

11 years ago | 1

| accepted

Answered
Attempted to access f(97); index out of bounds because numel(f)=96.
You are trying to access an array element that does not exist. Consider: >> X = [1,2,3] % only three elements X = ...

11 years ago | 0

| accepted

Answered
Finding the value of a variable for specific dates
You could use <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|> to create a logical index and then use this index ...

11 years ago | 0

Answered
How to store the cell array elements into logical array?
The answer depends on information that you have not given us. For example how many elements |mprset| has, and what values those ...

11 years ago | 0

Answered
In an assignment A(I) = B, the number of elements in B and I must be the same. Error in odev_3_c (line 9) fprime(1)=x.*cos(3*x); >>
You defined |x| to be a vector of values |x=0:1:4;|, which means that |x.*cos(3*x)| will _also_ be a vector of values. But you t...

11 years ago | 1

| accepted

Answered
Sum nX2 matrix
Although there is already an accepted answer to this question, the accepted answer misses the much simpler and neater alternativ...

11 years ago | 0

Answered
getting the following error Index exceeds matrix dimensions. Error in recur (line 32) y(i) = -a1*y(i-N:i-1)' + b1*x(i-N:i-N+M)';
You are trying to access an array element that does not exist. Consider: >> X = [1,2,3] % only three elements X = ...

11 years ago | 0

Answered
Sum of RGB components
Currently the numeric class is <http://www.mathworks.com/help/matlab/ref/uint8.html |uint8|>, which only supports maximum value ...

11 years ago | 1

| accepted

Answered
Read text file using MATLAB
Use <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|>: fid = fopen(filename,'rt'); C = textscan(fid,fo...

11 years ago | 1

Answered
read date from character string
This is easy using |regexp| to match the date substring: C = {'GOME_O3-NO2-NO2Tropo-BrO-SO2-H2O-HCHO_L2_20151031233116_051_...

11 years ago | 0

| accepted

Answered
Picking random points...
You can simply generate some indices to pick value from the vector |t|. I have shown you *uniformly distributed* random indices,...

11 years ago | 0

| accepted

Answered
problem with numbers in for loop that gives NaN
Although the code is *very inefficient* (see below), it does not generate NaN's for me: >> s(1:24) ans = Columns 1 t...

11 years ago | 0

| accepted

Load more