Answered
How to eliminate rows with NaN elements?
rows = any(isnan(myMatrix),2); myMatrix(rows,:) = [];

11 years ago | 3

| accepted

Answered
How to do counter in matlab?
I am still guessing here. Maybe this is what you want? (I am assuming M is square) load M.dat t = 600; q = zero...

11 years ago | 0

Answered
Editing a function to return a value that shows how many times a recursive function is called
See this link: http://www.mathworks.com/matlabcentral/answers/195865-fibonacci-program-makes-matlab-go-busy-forever You co...

11 years ago | 0

Answered
Choose certain matrix elements from a matrix
You could use logical indexing for this. E.g., z = r < R; % Logical result for 1's locations z = z(:); % Turn into colum...

11 years ago | 0

Answered
what does inner matrix dimensions must agree matlab error?
This error can often be fixed by replacing the * operator (matrix multiply) with the .* operator (element-wise multiply). Look a...

11 years ago | 0

Answered
narginchk and varargin in MATLAB
narginchk(7, 7) throws an error if the number of input arguments is less than 7 or greater than 7 (i.e., the number of input arg...

11 years ago | 0

Answered
Give me an hint
Hint: doc find

11 years ago | 1

Answered
Optimize/speed up a big and slow matrix operation with addition and bsxfun?
Assuming you have a C compiler available, here is a simple C mex routine to do the calculation. Could possibly be sped up even m...

11 years ago | 0

| accepted

Answered
How to increase the precision in my output using structures
I would assume s(1).pixels is some type of integer class instead of double, so you are getting an integer result. Either convert...

11 years ago | 0

Answered
how to solve this question using two loops?
Big Hint: Suppose the grid is M x N. You've got (M+N) total moves to make, with M of them being "down" and N of them being "r...

11 years ago | 0

| accepted

Answered
How to plot multiple functions on one graph>
plot3 with hold on should have worked. That being said, looks like the last three cases have vo typos to me, since vo is all 0's...

11 years ago | 2

| accepted

Answered
load a file with 'dir'
You are getting the results of dir from a different directory than the current directory. I.e., you explicitly put the path in t...

11 years ago | 0

| accepted

Answered
Derivative of a Function
If you have the Symbolic Toolbox: >> g = @(x) exp(x^2-2) g = @(x)exp(x^2-2) >> syms x >> diff(g(x)) ans...

11 years ago | 0

| accepted

Answered
The plot for t and ssdot in the following code cannot be displayed as it shows a vector length mismatch. Please suggest how I can get around it...
Your loop is for i=1:n+1 So the last iteration increases the size of ssdot when this line is encountered: ssdot(1,i...

11 years ago | 0

| accepted

Answered
how to concatinate two array values in one array
A3 = [A1 A2];

11 years ago | 0

| accepted

Answered
How to determine the MATLAB version when compiling C/C++ mex files
After reconsidering the fact that I no longer have access to the many MATLAB versions that I used to (changed jobs), I realize t...

11 years ago | 3

Answered
Insert numbers of a matrix B in matrix A (only in odd indexes).
k = i + j; C = zeros(1,k); C(1:2:end) = A; C(2:2:end) = B;

11 years ago | 1

| accepted

Answered
How to determine the MATLAB version when compiling C/C++ mex files
mxCreateUninitNumericMatrix has been in the libraries for many years as an exported function, at least as far back as R2006 or s...

11 years ago | 2

Answered
Attempted to access x_set(:,100); index out of bounds because size(x_set)=[7600,1] help
Typically one would remove entire rows or entire columns if you want to preserve the 2D matrix. By removing individual elements ...

11 years ago | 1

Answered
Most efficient way to add multiple sparse matrices in a loop in MATLAB
Unless you know in advance the pattern of the non-zero spots and can exploit that, then I think you are stuck. At every iteratio...

11 years ago | 1

Answered
How to optimize this matlab code?
I assume you are trying to vectorize this for speed purposes. In your current code, the x(:,:,k) expression copies data, and the...

11 years ago | 2

Answered
Find the inear indices of a specific value in a 3d matrix using the positions of a 2d matrix
Another way: find(bsxfun(@and,A==2,B==1))

11 years ago | 2

Answered
Error using * inner matrix dimensions must agree
Most likely i is not a scalar, hence the error. Try stopping on the error and then examining the dimensions to see what is going...

11 years ago | 0

Answered
I want Seperate Matrices for different values of n . (Im new to Matlab)
Don't do this! See these links for better solutions: http://www.mathworks.com/matlabcentral/answers/143-how-do-i-make-a-serie...

11 years ago | 0

Answered
Is it faster to use array size as an input or calculate size
For ease of use, typically the size would be generated inside the function to make sure there was no mismatch. For speed, this c...

11 years ago | 1

Answered
Exponential Function using Taylor series
1) You need to turn your factorial script into a function. However, note that MATLAB has a function called factorial already. So...

11 years ago | 1

| accepted

Answered
second order differential equation using ode45 and an events option: (195/32) * D2y + 0.005*(Dy)^2 = 0
y at 5 seconds is *not* y(5). You need to examine the variable *t* to determine time, not y. So pass in t and base your event on...

11 years ago | 1

| accepted

Answered
I'm trying to plot the golden ratio to show that it converges
Just add a line to calculate the ratio at each step. E.g., Initialize prior to the loop: f_ratio = [1 1]; Then add in...

11 years ago | 2

| accepted

Answered
hi. i got a problem to convert this equation into Matlab code perhaps can help me. it is about summation. thanks
Assuming the variables are each vectors of size N: sum((theta_bo - theta_mbo).^2) + sum((theta_to - theta_mto).^2)

11 years ago | 0

Answered
How to normalize values in a matrix to be between 0 and 1?
NormRows = sqrt(sum(Ypred.*Ypred,2)); Ynorm = bsxfun(@rdivide,abs(Ypred),NormRows);

11 years ago | 0

Load more