Respondida
How to iteratively split a matrix into multiple matrices according to a condition?
Assuming values in 1st column are non-negative, you could put the results into a cell array: M = your matrix M1 = M(:,1)...

más de 8 años hace | 1

| aceptada

Respondida
How to combine 4 Matrices into one matrix
E.g., result = zeros(m,p,n); % assuming your matrices are m x p sized for k=1:n result(:,:,k) = the matrix calcul...

más de 8 años hace | 0

Respondida
Incorrect results using Runge Kutta 5th order method
I have already answered this on your other thread, but will re-post here. The 'h' variable in your t and z updates is supposed t...

más de 8 años hace | 0

| aceptada

Respondida
Runge Kutta 5th order help, error message "Index exceeds matrix dimensions."
You don't have any x(i+1)=etc line. Since you don't set the next value of x, when you get to the second loop iteration the x(2) ...

más de 8 años hace | 0

| aceptada

Pregunta


Mex inplace change problems R2015b and later
This post is to alert mex programmers of a change in R2015b and later that makes inplace changes more hazardous than they used t...

más de 8 años hace | 3 respuestas | 3

3

respuestas

Respondida
I have a matrix A (32000x2). I want to create a new matrix from matrix A, with only value 1 or 0 in coloumn 2 and delete other rows (which have decimal values).
A = your 32000x2 matrix A2 = A(:,2); % 2nd column of A result = A( A2==0 | A2==1, : ); % subset of A where 2nd column is 0 ...

más de 8 años hace | 0

| aceptada

Respondida
How do i this in an efficient way?
C = sum(A(sub2ind(size(A),B(1:end-1),B(2:end))));

más de 8 años hace | 0

| aceptada

Respondida
I am trying to run the following code-
dataset has only 8 columns, but you are trying to pick off columns 1:40 and 41, hence the error. You need to reexamine your code...

más de 8 años hace | 0

Respondida
Why does the first for loop stop at n=2999 instead of 3000 when t=0.6 and k=1/5000?
Floating point calculations are not always exact because MATLAB uses IEEE double precision for the calculations you are doing, a...

más de 8 años hace | 1

| aceptada

Respondida
Do the inverse operation of this reshape?
Are you just trying to recover an original single line string? E.g., str = char(key+'0');

más de 8 años hace | 0

Respondida
How to take an average every four columns?
x = your 64x1844 matrix result = reshape(mean(reshape(x.',4,[])),size(x,2)/4,[]).';

más de 8 años hace | 0

| aceptada

Respondida
How would find acceleration from two columns of data using this formulae? (I have velocity and time)
Hint: Given an Mx2 matrix called vt with first column velocity and second column time, look at using the diff( ) function on the...

más de 8 años hace | 0

| aceptada

Respondida
how to sum multiple matrics inside a cell array?
result = sum([A{:}]);

más de 8 años hace | 2

| aceptada

Respondida
Can someone explain to me why this sub-array behaves this way?
The (i,j)'th element of the result is made up of the (row_index(i),col_index(j)) element of the source. Since you have two row i...

más de 8 años hace | 0

Respondida
How can I call the first value from a for loop into a vector?
Remember the starting values prior to the loop. E.g., A = a; B = b; Then after the loop concatenate: vec = [A,B,...

más de 8 años hace | 1

Respondida
Elegantly refer to the second output from a function
Unless the function has an input argument syntax that specifies only returning B, you can't do this. You can throw away that A i...

más de 8 años hace | 0

Respondida
New to matlab and am getting index exceed matrix dimensions error
Did you mean that last p to be p2? E.g., should this S = sum(abs(y - p(1)*x.^2 - p(2)*x - p(3))); be this instead ...

más de 8 años hace | 0

Respondida
Apply function to all fields of a structure
What you have is likely the best way to do this. Since there will need to be a loop of some sort to do this anyway (even if it i...

más de 8 años hace | 0

Respondida
How does this code sum the first 100 even integers?
The code picks off the values of ctr that are even and adds them into the variable called sum (a lousy name for a variable btw b...

más de 8 años hace | 1

Respondida
Pick 5 Unique Random Numbers
A = your matrix n = number of elements of A to pick at a time (must be exactly divisible in numel(A)) x = reshape(randpe...

más de 8 años hace | 1

| aceptada

Respondida
OR, Matrices and equality
The == and | operations you are doing are element-wise operations, so you get an element-wise result according to the precedence...

más de 8 años hace | 1

| aceptada

Respondida
How do I use each value in a vector as its own variable to be tested in relation to another variable in its respective vector?
Use element-wise operators. E.g., x = a - b ./ c; % The ./ operator with the dot is element-wise division There also ele...

más de 8 años hace | 0

Respondida
Hello can someone show me a simple code to show the earths orbit around the sun using ordinary differential equations.
Your biggest problem is that you have a 4-element state vector defined with y0 (indicating only x-y plane motion), but your deri...

más de 8 años hace | 0

Respondida
Number of Elements Between 2 Elements in a matrix.
Assuming the matrix has exactly two nonzero entries: M = your matrix f = find(M'); % Transpose to get the row data into ...

más de 8 años hace | 0

Respondida
Maximum Recursion limit of 500 Reached Error.
You need to rewrite your logic so that your circle3 function has a way to return to the caller. As it is now, the only thing tha...

más de 8 años hace | 2

Respondida
Why is my plot not showing anything?
Use element-wise division: y = ((x+5).^2)./(4+3*x.^2);

más de 8 años hace | 1

| aceptada

Respondida
How to add values from two different arrays into a matrix
On later versions of MATLAB: c = a + b; On earlier versions of MATLAB: c = bsxfun(@plus,a,b); In MATLAB, variabl...

más de 8 años hace | 1

Respondida
Matlab confusion of function and variable names after load
The load command 'poof'ed a variable into the function workspace after the parser had parsed the m-file and associated "alpha" w...

más de 8 años hace | 0

| aceptada

Respondida
mex error. undefined reference
Unless all of the source C files are explicitly #include in your nlopt_optimize.c file, you must list them explicitly in the mex...

más de 8 años hace | 1

Cargar más