3.201 total contributions since 2007

Interested in external applications, mex & engine applications with Fortran, C, C++, etc, particularly in the areas of speed improvement and memory management efficiencies.

Answered

Highest power of 2 that divides n.

In addition to David's comments, you need to do all of the calculations symbolically, so all of these should be sym: 2, i, r.

Highest power of 2 that divides n.

In addition to David's comments, you need to do all of the calculations symbolically, so all of these should be sym: 2, i, r.

etwa 22 Stunden ago | 0

| accepted

Answered

Can someone help me convert C++ to Matlab

The += and *= operators behave as follows: total_salary += daily_salary; becomes total_salary = total_salary + daily_salary; ...

Can someone help me convert C++ to Matlab

The += and *= operators behave as follows: total_salary += daily_salary; becomes total_salary = total_salary + daily_salary; ...

7 Tage ago | 0

Answered

Operands to the || and && operators must be convertible to logical scalar values

Did you mean this for u = 1:height<=u for v = 1:width<=v to be this for u = 1:height for v = 1:width

Operands to the || and && operators must be convertible to logical scalar values

Did you mean this for u = 1:height<=u for v = 1:width<=v to be this for u = 1:height for v = 1:width

8 Tage ago | 0

| accepted

Answered

find max of vector

Two things. FIrst, you need to initialize pos = 1 before the loop starts. And second, you need to modify your if-test to do tw...

find max of vector

Two things. FIrst, you need to initialize pos = 1 before the loop starts. And second, you need to modify your if-test to do tw...

8 Tage ago | 0

Answered

How to define an axis based on multiple quaternions?

Assume you have the following: q1 = quaternion from ECI to BODY at time1 (i.e., BODY1 frame) q2 = quaternion from ECI to BODY ...

How to define an axis based on multiple quaternions?

Assume you have the following: q1 = quaternion from ECI to BODY at time1 (i.e., BODY1 frame) q2 = quaternion from ECI to BODY ...

8 Tage ago | 0

| accepted

Answered

Repeat elements of a vector as matrixes in a multidimensional array.

Another way: m = size of 1st dimension n = size of 2nd dimension v = your row vector result = reshape(repmat(v,m*n,1),m,n,[]...

Repeat elements of a vector as matrixes in a multidimensional array.

Another way: m = size of 1st dimension n = size of 2nd dimension v = your row vector result = reshape(repmat(v,m*n,1),m,n,[]...

8 Tage ago | 1

Answered

Sorting numbers in an array without sort function

Simply set your "finished" flag depending on whether a swap was done or not. E.g., while true finished = 1; for i=1:s...

Sorting numbers in an array without sort function

Simply set your "finished" flag depending on whether a swap was done or not. E.g., while true finished = 1; for i=1:s...

13 Tage ago | 0

| accepted

Answered

Need help finding intercept in a polynomial function

Why can't you just find the real roots of f(x)-600? What am I missing here?

Need help finding intercept in a polynomial function

Why can't you just find the real roots of f(x)-600? What am I missing here?

13 Tage ago | 0

| accepted

Answered

Picking a random row of a matrix

k = randi(size(Y,1)); % the random row index Y(k,:) is the random row

Picking a random row of a matrix

k = randi(size(Y,1)); % the random row index Y(k,:) is the random row

13 Tage ago | 0

| accepted

Answered

Replacing all elements in a row with zeros, if atleast one of the elements in the row is greater than 1

Another method if you want the replacement in-place: A(any(A>1,2),:) = 0;

Replacing all elements in a row with zeros, if atleast one of the elements in the row is greater than 1

Another method if you want the replacement in-place: A(any(A>1,2),:) = 0;

13 Tage ago | 0

| accepted

Answered

Large, unused cell aray in memory still slows down calculation significantly

Can you clarify if the above code is included in your timings? For all we know, you are simply showing that creating 44100 sepa...

Large, unused cell aray in memory still slows down calculation significantly

Can you clarify if the above code is included in your timings? For all we know, you are simply showing that creating 44100 sepa...

13 Tage ago | 0

Answered

ActiveX: how to pass a string array to cst in matlab？

Couple of things you might also try sWidth={'0.5';'1.1';'2.2';'3.3'}; or sWidth={'0.5';'1.1';'2.2';'3.3'}; sWidth = cellfun(...

ActiveX: how to pass a string array to cst in matlab？

Couple of things you might also try sWidth={'0.5';'1.1';'2.2';'3.3'}; or sWidth={'0.5';'1.1';'2.2';'3.3'}; sWidth = cellfun(...

14 Tage ago | 0

Answered

I am having a lot of trouble with the built in mode function

You have inadvertently created a variable called "mode" that is shadowing the MATLAB mode( ) function. Track down where that is ...

I am having a lot of trouble with the built in mode function

You have inadvertently created a variable called "mode" that is shadowing the MATLAB mode( ) function. Track down where that is ...

14 Tage ago | 0

| accepted

Answered

Debugging matrix dimensions error

How to debug: Type the following at the MATLAB prompt: dbstop if error Then run your code. When the error occurs, the code wi...

Debugging matrix dimensions error

How to debug: Type the following at the MATLAB prompt: dbstop if error Then run your code. When the error occurs, the code wi...

15 Tage ago | 0

Answered

Table of Matlab release features

Note that a similar list of version specific mex related features (mxArray changes, API functions, etc.) can be found here in th...

Table of Matlab release features

Note that a similar list of version specific mex related features (mxArray changes, API functions, etc.) can be found here in th...

15 Tage ago | 3

Answered

Adding a row to an unknown matrix - the row consists of the mean value of the columns of the unknown matrix.

Hints: doc mean The last row of the matrix A is A(end,:). Then ask yourself: What would be the indexing of one row beyond "en...

Adding a row to an unknown matrix - the row consists of the mean value of the columns of the unknown matrix.

Hints: doc mean The last row of the matrix A is A(end,:). Then ask yourself: What would be the indexing of one row beyond "en...

15 Tage ago | 0

| accepted

Answered

Matrix multiplication using multicore

The matrix multiply operator * calls a highy optimized compiled BLAS library to do this calculation. The BLAS library is alread...

Matrix multiplication using multicore

The matrix multiply operator * calls a highy optimized compiled BLAS library to do this calculation. The BLAS library is alread...

18 Tage ago | 0

Answered

How to write a function

MATLAB is case sensitive, Output is not the same variable as output. Also, you need to square the Top value, and depending on w...

How to write a function

MATLAB is case sensitive, Output is not the same variable as output. Also, you need to square the Top value, and depending on w...

19 Tage ago | 0

Answered

How to efficiently do matrix multiplication for 2 specific dimensions of the tensor?

Some FEX options that might work for you (some require an installed C compiler): https://www.mathworks.com/matlabcentral/fileex...

How to efficiently do matrix multiplication for 2 specific dimensions of the tensor?

Some FEX options that might work for you (some require an installed C compiler): https://www.mathworks.com/matlabcentral/fileex...

20 Tage ago | 0

| accepted

Answered

ode45 given a systems of equations help

First, look over the examples in the ode45 doc. Then figure out the order of your system, and that will tell you the size of yo...

ode45 given a systems of equations help

First, look over the examples in the ode45 doc. Then figure out the order of your system, and that will tell you the size of yo...

21 Tage ago | 0

Answered

Create an Array of vectors within a for loop

If you want to store the column vectors, you could use cell arrays. E.g., k = 1; for j=0:100:5000; : [PXX{k},F{k...

Create an Array of vectors within a for loop

If you want to store the column vectors, you could use cell arrays. E.g., k = 1; for j=0:100:5000; : [PXX{k},F{k...

21 Tage ago | 0

| accepted

Answered

ODE matlab, handling variables

You can't do this if the derivative yd depends on k. The ode solvers need to have consistency when calling the derivative funct...

ODE matlab, handling variables

You can't do this if the derivative yd depends on k. The ode solvers need to have consistency when calling the derivative funct...

21 Tage ago | 0

| accepted

Answered

two body problem using ode45

The RK methods don't match up well with the orbit DE problem because the integration errors tend to be systematic (e.g., always ...

two body problem using ode45

The RK methods don't match up well with the orbit DE problem because the integration errors tend to be systematic (e.g., always ...

21 Tage ago | 1

Answered

Duffing Oscillator issue. "Keep getting Unable to perform assignment because the left and right sides have a different number of elements."

t is a vector, so your cos(omega*t) is a vector. You need to use cos(omega*t(n)) there.

Duffing Oscillator issue. "Keep getting Unable to perform assignment because the left and right sides have a different number of elements."

t is a vector, so your cos(omega*t) is a vector. You need to use cos(omega*t(n)) there.

21 Tage ago | 0

Answered

double integration of acceleration data with offset

You put a constant offset into the acceleration, not the position. The result of double integrating a constant is going to be a ...

double integration of acceleration data with offset

You put a constant offset into the acceleration, not the position. The result of double integrating a constant is going to be a ...

21 Tage ago | 0

| accepted

Answered

Need help verifying code for Euler MEthod, RK2 and RK4

Your biggest problem is that you don't have the differential equations coded correctly. And the main cause of that is because y...

Need help verifying code for Euler MEthod, RK2 and RK4

Your biggest problem is that you don't have the differential equations coded correctly. And the main cause of that is because y...

21 Tage ago | 0

| accepted

Answered

Numerically Integrating the differential equation below?

You've got two 2nd order DE's, so that means you have a 4th order system (2x2=4) and thus your state vector will contain four el...

Numerically Integrating the differential equation below?

You've got two 2nd order DE's, so that means you have a 4th order system (2x2=4) and thus your state vector will contain four el...

22 Tage ago | 0

Answered

Generate all possible combinations for the column vectors of a matrix

E.g., >> B = [1;2]; >> n = 3; >> Bcell = arrayfun(@(k)B,1:n,'uni',false); >> C = allcomb(Bcell{:}) Warning: NARGCHK will be...

Generate all possible combinations for the column vectors of a matrix

E.g., >> B = [1;2]; >> n = 3; >> Bcell = arrayfun(@(k)B,1:n,'uni',false); >> C = allcomb(Bcell{:}) Warning: NARGCHK will be...

22 Tage ago | 1

| accepted

Answered

Removing single quotations from a character array

Your answer does not include the bounding single quotation marks ... that is just a display artifact for how MATLAB prints chara...

Removing single quotations from a character array

Your answer does not include the bounding single quotation marks ... that is just a display artifact for how MATLAB prints chara...

22 Tage ago | 0

Answered

Help, I don't understand why the output multiplies everything by 1.0e+03

That's just the default way that MATLAB displays the numbers, rather that tacking e+03 to each number individually. You could u...

Help, I don't understand why the output multiplies everything by 1.0e+03

That's just the default way that MATLAB displays the numbers, rather that tacking e+03 to each number individually. You could u...

24 Tage ago | 0

| accepted