Answered
Is there any way to count operations/flops in an iteration of Matlab code?
<http://www.mathworks.com/matlabcentral/fileexchange/50608-counting-the-floating-point-operations--flops-> <http://www.mathwo...

10 years ago | 0

| accepted

Answered
Average of first component in 3D matrix
Assuming that your first dimension (rows) is an exact multiple of the number of values that you wish to |mean| over, then you ca...

10 years ago | 0

| accepted

Answered
How do i fix the error in this code? I says "Illegal use of reserved keyword "case""
This is a perfect example of why formatting and indenting code correctly is so important. Although beginners think that all of t...

10 years ago | 2

Answered
factorial function won't take a cell argument independently of it's class (double, integer, etc)
This is because of your MATLAB version. Here using MATLAB 2010b: >> factorial(uint16([3.4 2.8])) ??? Error using ==> fac...

10 years ago | 2

| accepted

Answered
Create vector/matrix inside function
You return it as an output argument. <http://www.mathworks.com/help/matlab/function-basics.html> Like the MATLAB documenta...

10 years ago | 1

| accepted

Answered
How to read a single line of a textfile without any delimiters to a matrix
>> str = '011010010100'; >> reshape(str-'0',3,[]).' ans = 0 1 1 0 1 0 0 1 0 ...

10 years ago | 1

| accepted

Answered
Extracting rows from a matrix based on values in columns
This is easy using <http://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: A = [3, 0.1234; 1, 0.1345; ...

10 years ago | 1

Answered
Matlab CSV parsing error?
The issue is that some of the strings seem to contain commas, which you are also using as column delimiters. Luckily for you the...

10 years ago | 1

Answered
How to count no. of time state occur in sequence and then divide by sequence no.?
>> V = [1,3,3,1,2,1,4,2,3,1,4,2,4,4,4,3,1,2,5,1]; >> [~,~,idx] = unique(V); >> prod(hist(idx,1:max(idx))/numel(V)) an...

10 years ago | 0

Answered
fprintf matrix same row and column
As an alternative to fprintf, |disp| also does the trick: >> m = randi([0 1], 8, 12); >> disp(m) 1 1 0 ...

10 years ago | 0

Answered
How can I convert a lena.bmp image to lena.tif?
The file type is not determined by the file extension (in fact on linux files are not even required to have a file extension). Y...

10 years ago | 0

Answered
write a math lab function that takes a string of characters as input argument and returns a string in which each vowel and consonant of the input string have been replaced by 'v' and 'c' respectively
Here is a solution in just one line using one <http://www.mathworks.com/help/matlab/ref/regexprep.html |regexprep|> call: >...

10 years ago | 0

Answered
How should I write this fprintf in order for it to work?
Beginners often complain that some function "does not work" properly, and very often they did not bother to read the documentati...

10 years ago | 0

| accepted

Answered
How to multiply all elements of matrix
prod(A(A~=0))

10 years ago | 0

Answered
Why the division of two positive values gives negative value?
You are using the wrong divide: you probably intended to use <http://www.mathworks.com/help/matlab/ref/rdivide.html array right ...

10 years ago | 0

| accepted

Answered
indexing string in function
*Words* >> C = regexp('the quick brown fox','\S+','match'); >> C([1,end]) ans = 'the' 'fox' *Letters* ...

10 years ago | 2

| accepted

Answered
Binary matrix to array of poitns
>> [y,x] = find(M.') y = 2 4 4 1 x = 1 1 2 3

10 years ago | 2

| accepted

Answered
Issue t<0 in an for t=-5:10 loop.
You don't need and |if|'s or the like, the simplest way is to use a logical comparison and convert this to double: int = do...

10 years ago | 0

Answered
Permutations of string without repetitions
>> unique(perms('AA'),'rows') ans = AA >> unique(perms('AB'),'rows') ans = AB BA >> unique(perms('ABA'),'...

10 years ago | 1

Answered
if i have two matrix how can make them same size by add zero column or row ?
M = [15,13,11,11,7,7,8,9,11,13,15,8,8,6,3,0,3]; X = [15,13,11,12,7,5,4,7,8,8,11,9,14,11,13]; tmp = zeros(2,max(numel...

10 years ago | 0

Answered
[SOS!!!!!!!] Plotting with if statement.
You made a mistake on these two lines: theta = linspace(thetas(k),thetas(k)+thetad,100); dum = (theta-thetas(k))/the...

10 years ago | 1

| accepted

Answered
Regular expressions: dealing with spaces
You were almost there: >> fmt = 'f *\d+ *min'; >> regexp('f 2000 min',fmt,'match') ans = f 2000 min >> regexp('f2000min',fm...

10 years ago | 1

| accepted

Answered
Is the log() function faulty?
The documentation tells us that in MATLAB <http://www.mathworks.com/help/matlab/ref/log.html |log|> calculates the natural logar...

10 years ago | 3

| accepted

Answered
Error in for and if cycles for average
Because you are using the wrong 'equals': * |=| is used for <http://www.mathworks.com/help/matlab/ref/specialcharacters.html...

10 years ago | 0

| accepted

Answered
Find common words in 2 strings
This works in MATLAB versions prior to R2013a: >> str1 = ('rabbit is eating grass near a tree'); >> str2 = ('rabbit is s...

10 years ago | 1

Answered
How can i collect number without using eval function ?
The safest and most versatile: num = str2double(input('Please enter a number:','s'));

10 years ago | 1

Answered
How to vectorize this ?
This does that same as your loop: beta = sum(bsxfun(@times,Aj,uj),2).';

10 years ago | 1

| accepted

Answered
How to design a proper script/code for estimating multiple parameters (more than three) for a model, without using 'lsqnonline'?
You could use <http://www.mathworks.com/help/optim/ug/lsqnonlin.html |lsqnonlin|>. Its application is quite straightforward, the...

10 years ago | 0

| accepted

Answered
how to cross over between 10 matrix randomly ?
Ugh... this is a *really bad idea*! Avoid creating dynamically named variables in MATLAB. This is *poor practice* as has been...

10 years ago | 0

| accepted

Answered
fall time of square wave
Try this: N = 200; % fake data: vec = ones(1,N); vec(randperm(N,5)) = 0; % detect zeros: idx = diff(vec)<0; ...

10 years ago | 0

Load more