Answered
Making a for loop that appends outputs in a matrix/array
"... I thought about making 33 different matrices (one from each output) and then combining them at the end but this seems count...

7 years ago | 0

| accepted

Answered
How to use CROSS with 3x1 Matrix on a 3xN Matrix
Unfortunately, the cross( ) function does not auto-expand the dimensions of the operands. So you would have to manually do this ...

7 years ago | 0

| accepted

Answered
Applying 3D Rotation Matrix
You can use this FEX submission by Matt J with your coordinate axes as the inputs to get the rotation matrix R: https://www.mat...

7 years ago | 0

| accepted

Answered
plotting projectile with drag
When doing physics problems, I would advise that you always include units and description in a comment off to the side to make s...

7 years ago | 0

| accepted

Answered
How to run Main.mexa64
As long as Main.mexa64 is on your path so MATLAB can see it: t = Main(a);

7 years ago | 0

Answered
Appending Arrays at the END!
E.g., A = B * C.'; % outer product A = A(:); % turn into column vector

7 years ago | 2

| accepted

Answered
How to make a QuickSort for 2 vectors?
See the 2nd output of the sort( ) function, and use that as an index to rearrange your signal. E.g., [t,x] = sort(time); s = s...

7 years ago | 0

Answered
Help me use this formula to complete this task (Runge–Kutta methods)
First, your derivative function should be obtained from your differential equation, not from the solution as you have it. You we...

7 years ago | 0

| accepted

Answered
Numerical Logical Statement Error
Both of your numbers are negative, so I don't think this test does what you intended. E.g., >> ct = 1; >> Us = -1.7280e+03 Us...

7 years ago | 0

| accepted

Answered
I get an Access violation reading location when using mxCreateCharMatrixFromStrings
You should show the entire code you are using, not just a snippet of it. Also, the fact that you have a typo in the function nam...

7 years ago | 0

| accepted

Answered
I need help solving an ODE using the Runge Kutta method. The values I obtain for "A" are correct, but the value I receive for "C" are incorrect.
Your signature of the derivative function is f2(A,C,t) not f2(A,t,C). So these lines: k6(k) = dt*f2((A(k)+0.5*k1(k)),t(k)+0...

7 years ago | 1

| accepted

Answered
For loop not working. Array indices must be positive integers or logical values.
This line on the first iteration when i=1 and j=1: y(j) = y +(1/(M+1))*x(i-j); You are indexing x(0). Also, you are trying to ...

7 years ago | 1

Answered
Binary Vector Frequency of 1's
b = your row vector of 1's and 0's result = cumsum(b) ./ (1:numel(b));

7 years ago | 1

| accepted

Answered
sum all columns in a matrix
Hint: Look at matrix multiplication.

7 years ago | 0

Answered
How to have multiple matlab instances access MEX function files
Multiple instances of MATLAB can certainly access and run the same mex routine. But based on the fact that you have a LINK erro...

7 years ago | 1

| accepted

Answered
How to put 2 vectors when the inner product is available
I'm not at all sure what you mean. Maybe this is what you want: result = 2*u(1)*v(1) - 3*u(1)*v(2) - 3*u(2)*v(1) + 5*u(2)*v(2) ...

7 years ago | 1

Answered
How can i solve equation but adding a constant (d^2u/dt^2)+4*(du/dt)-(3*u)+5=0)
The general solution is the homogeneous solution (to the "= 0" equation) which you already have plus any particular specific sol...

7 years ago | 0

| accepted

Answered
Finding real root of Newton's cubic
The third line: x(0) = 1; You have a 0 index. You need to start your indexing with 1, not 0. You've got other issues with you...

7 years ago | 0

Answered
How to multiply part of a matrix with another matrix
result = M1 .* M2(:,1:2); If you want to replace part of M2 with this result, then simply M2(:,1:2) = M1 .* M2(:,1:2);

7 years ago | 1

| accepted

Answered
I am getting an error in function definition.
gen_Kalman_coefs needs to have the proper function syntax. E.g., function [Kph, Kf] = gen_Kalman_coefs (R, Q, S0, F, G, H, N) ...

7 years ago | 0

| accepted

Answered
matrix multiplication dimension issues
If the formula in the article has the calculation as async = spect1(:, 2:n) * N * spect2(:, 2:n)'/(n-2) , and N is an (n-1)x(n-1...

7 years ago | 0

Answered
Using int64 for changing the data class
int64(x), where x is is a shorter signed or unsigned integer class, will effectively attach the appropriate number of 0 bytes to...

7 years ago | 1

| accepted

Answered
How to input and output variable in mex function
Some issues: b = mxGetPr(plhs[1]); d = mxGetPr(plhs[2]); The above lines crash MATLAB when you try to use...

7 years ago | 1

| accepted

Answered
how to do bitxor operation of two 1*255 matrix
It's not entirely clear to me what operation you really want, but if the elements of h1 and h2 represent "bits", then you could ...

7 years ago | 0

Answered
Get x and y coordinates of motion from ode45
You've got a 4th order system (2 equations for x and y, each 2nd order --> 2 x 2 = 4), so your state vector will need to be 4 el...

7 years ago | 2

| accepted

Answered
Im having trouble with the forward eulers method.
A basic outline would be: dt = _____; % the step size, you fill this in n = _____: % number of steps, you fill this in x = ze...

7 years ago | 0

Answered
speed up run time of mldivide function.
You might want to take a look at the Tim Davis Factorize FES submission: https://www.mathworks.com/matlabcentral/fileexchange...

7 years ago | 1

Answered
MATLAB returns empty string from C-MEX file
It is hard to believe that this code did not crash MATLAB. The issues: char *code; <-- This is an uninitialized pointer .....

7 years ago | 0

| accepted

Answered
How do I use either "printf()" or "mexPrintf()" when either call gets me "Unknown function or variable"?
Typically use disp( ) or display( ) or fprintf( ) to display variables in the command window.

7 years ago | 0

| accepted

Load more