3 039 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

2D summation loop

Take the denominator for instance. Literally written out, this would be denominator = 0; for k=1:K denominator = denomin...

2D summation loop

Take the denominator for instance. Literally written out, this would be denominator = 0; for k=1:K denominator = denomin...

ungefär 12 timmar ago | 0

| accepted

Answered

Pass pointer to scalar variable in mex function

"... The only way I've gotten around this before is by making the scalar variable into a vector and just using the first element...

Pass pointer to scalar variable in mex function

"... The only way I've gotten around this before is by making the scalar variable into a vector and just using the first element...

ungefär 13 timmar ago | 0

Answered

Get a matrix by interaction

Maybe use cell arrays. E.g., BCG{gen} = horzcat (dx1, dy1, dx2, dy2, dx3, dy3, SLL); Then everywhere downstream in your code, ...

Get a matrix by interaction

Maybe use cell arrays. E.g., BCG{gen} = horzcat (dx1, dy1, dx2, dy2, dx3, dy3, SLL); Then everywhere downstream in your code, ...

en dag ago | 0

| accepted

Answered

Implicit expansion with empty arrays

In the 1st case, you are expanding a dimension of 1 (the 3rd dimension of the first operand) to 0, so it is scalar expansion. I...

Implicit expansion with empty arrays

In the 1st case, you are expanding a dimension of 1 (the 3rd dimension of the first operand) to 0, so it is scalar expansion. I...

2 dagar ago | 0

| accepted

Answered

how to add all 2d matrices in a 4D matrix???

sum(sum(your_matrix,4),3) or sum(reshape(your_matrix,10,50,[]),3)

how to add all 2d matrices in a 4D matrix???

sum(sum(your_matrix,4),3) or sum(reshape(your_matrix,10,50,[]),3)

2 dagar ago | 0

Answered

Save values in each iteration

The loops aren't needed. E.g., Ccl = 21; % Number of column elements gene = 5; % Number of times the column is generated min...

Save values in each iteration

The loops aren't needed. E.g., Ccl = 21; % Number of column elements gene = 5; % Number of times the column is generated min...

3 dagar ago | 0

Answered

How to find the angle between two quaternions?

For example purposes I am using the coordinate frames as ECI and BODY Q1 = quaternion from ECI->BODY1 Q2 = quaternion from ECI...

How to find the angle between two quaternions?

For example purposes I am using the coordinate frames as ECI and BODY Q1 = quaternion from ECI->BODY1 Q2 = quaternion from ECI...

6 dagar ago | 1

| accepted

Answered

for loop, conditional operator

You are creating the variable filling_degree_regionI_new inside a condition if statement. If the condition is never met, the va...

for loop, conditional operator

You are creating the variable filling_degree_regionI_new inside a condition if statement. If the condition is never met, the va...

7 dagar ago | 0

| accepted

Answered

Get next or prior single precision value MATLAB function ?

The designers of IEEE floating point were brilliant. The next largest value (in magnitude) is always obtained by just adding 1 t...

Get next or prior single precision value MATLAB function ?

The designers of IEEE floating point were brilliant. The next largest value (in magnitude) is always obtained by just adding 1 t...

11 dagar ago | 0

| accepted

Answered

Arrays from c to matlab.

v is pointer-to-double, *v is double. Everywhere inside generation() that you use v it needs to be *v instead.

Arrays from c to matlab.

v is pointer-to-double, *v is double. Everywhere inside generation() that you use v it needs to be *v instead.

12 dagar ago | 0

Answered

Shuffling and Using a Set of Six 52-Card Decks

It is not entirely clear what you want. Maybe this instead of the loop? shuffledcard = decksofcards(randomcards);

Shuffling and Using a Set of Six 52-Card Decks

It is not entirely clear what you want. Maybe this instead of the loop? shuffledcard = decksofcards(randomcards);

14 dagar ago | 0

Answered

How to add new elements in a big array

Maybe assign into elements of N with indexing: N(j) = length(group);

How to add new elements in a big array

Maybe assign into elements of N with indexing: N(j) = length(group);

23 dagar ago | 1

| accepted

Answered

filling each row of a matrix using values from a vector

Assuming x starts as a 4x4 matrix (instead of a 3x4 matrix): x(sub2ind(size(x),(1:numel(u))',u)) = 1;

filling each row of a matrix using values from a vector

Assuming x starts as a 4x4 matrix (instead of a 3x4 matrix): x(sub2ind(size(x),(1:numel(u))',u)) = 1;

24 dagar ago | 0

| accepted

Answered

Convert double array into column vector

Maybe one of these? reshape(f,1,[]) f(:).'

Convert double array into column vector

Maybe one of these? reshape(f,1,[]) f(:).'

24 dagar ago | 0

Answered

uint16 to uint8

u16 = your uint16 variable u8 = typecast(u16,'uint8');

uint16 to uint8

u16 = your uint16 variable u8 = typecast(u16,'uint8');

24 dagar ago | 0

| accepted

Answered

API changes in R2019a?

I don't know if this is the cause of your problems, but there was a change to the low level mxArray variable structure in R2019a...

API changes in R2019a?

I don't know if this is the cause of your problems, but there was a change to the low level mxArray variable structure in R2019a...

24 dagar ago | 0

Answered

complex number inside cell array

This might be done better with a loop, but here is a method using cellfun c = your cell array containing complex numbers resul...

complex number inside cell array

This might be done better with a loop, but here is a method using cellfun c = your cell array containing complex numbers resul...

24 dagar ago | 0

| accepted

Answered

RK4 orbit problem

Couple of things: 1) You have picked the most convoluted method of coding your equations. Having four separate variables for yo...

RK4 orbit problem

Couple of things: 1) You have picked the most convoluted method of coding your equations. Having four separate variables for yo...

24 dagar ago | 1

Answered

Portable declaration of REAL variables in mex gateway for Fortran

The REAL(kind(0.0D0)) vs REAL*8 discussion (and INTEGER*4 vs INTEGER etc) is a compiler issue, not a mex issue. As long as your...

Portable declaration of REAL variables in mex gateway for Fortran

The REAL(kind(0.0D0)) vs REAL*8 discussion (and INTEGER*4 vs INTEGER etc) is a compiler issue, not a mex issue. As long as your...

25 dagar ago | 0

Answered

The return type of mxIsDouble, mxIsSingle, and mxIsClass (mex for Fortran)

Do what the documentation says and use INTEGER*4. Yes, it is non-standard but you are very unlikely to run into a compiler that...

The return type of mxIsDouble, mxIsSingle, and mxIsClass (mex for Fortran)

Do what the documentation says and use INTEGER*4. Yes, it is non-standard but you are very unlikely to run into a compiler that...

25 dagar ago | 0

Answered

How can I generate random single precision (float32) numbers ?

For the generic answer with all bit patterns possible and selected with equal probability (including inf & nan & denorm) your "b...

How can I generate random single precision (float32) numbers ?

For the generic answer with all bit patterns possible and selected with equal probability (including inf & nan & denorm) your "b...

28 dagar ago | 1

Answered

How can I show the 4-byte hex representation of a single precison float value?

s = your single float number h = dec2hex(typecast(s,'uint32'),8) And the reverse is s = typecast(uint32(hex2dec(h)),'single')...

How can I show the 4-byte hex representation of a single precison float value?

s = your single float number h = dec2hex(typecast(s,'uint32'),8) And the reverse is s = typecast(uint32(hex2dec(h)),'single')...

30 dagar ago | 0

| accepted

Answered

Error using mex: undefined reference for user build package

Try looking in the MATLAB/R2019a/extern/lib folder for versions of these files appropriate for your system. They might have slig...

Error using mex: undefined reference for user build package

Try looking in the MATLAB/R2019a/extern/lib folder for versions of these files appropriate for your system. They might have slig...

ungefär en månad ago | 0

Answered

Problem with MexFunction and MexGetPr

Impossible to answer without seeing the code for the functionsum( ) function. Maybe you could post that? Maybe all you need to...

Problem with MexFunction and MexGetPr

Impossible to answer without seeing the code for the functionsum( ) function. Maybe you could post that? Maybe all you need to...

ungefär en månad ago | 0

| accepted

Answered

Unexpected numerical error in built-in cross product

When I calculate things from scratch, everything works to the expected precision. E.g., run this code: % From post rTAN = [6.2...

Unexpected numerical error in built-in cross product

When I calculate things from scratch, everything works to the expected precision. E.g., run this code: % From post rTAN = [6.2...

ungefär 2 månader ago | 2

Answered

MEX crashes when called twice in succession (Same input)

Here is one cause of a crash: mwIndex *subs; subs[0]=1; subs[1]=1; You are dereferencing an uninitialized pointer on that se...

MEX crashes when called twice in succession (Same input)

Here is one cause of a crash: mwIndex *subs; subs[0]=1; subs[1]=1; You are dereferencing an uninitialized pointer on that se...

ungefär 2 månader ago | 0

Answered

Change sign of descending values

Is this what you want? x = your vector of values d = [1;diff(x)]; x(d<0) = -x(d<0);

Change sign of descending values

Is this what you want? x = your vector of values d = [1;diff(x)]; x(d<0) = -x(d<0);

ungefär 2 månader ago | 1

| accepted

Answered

Trouble with declaring function output

function data = importer

Trouble with declaring function output

function data = importer

ungefär 2 månader ago | 1

| accepted

Answered

how to iterate a matrix for multiple times

E.g., here is a possible outline n = 30; % the number of iterations M = rand(5,5); % some initial matrix for k=1:n M = 2...

how to iterate a matrix for multiple times

E.g., here is a possible outline n = 30; % the number of iterations M = rand(5,5); % some initial matrix for k=1:n M = 2...

ungefär 2 månader ago | 1

| accepted

Answered

Using the dms2degree Command Sequentially to Populate an Array using a Sub-routine

With a for-loop, you need to use A in all of your indexing and use the [ ] brackets to form a vector input (and spell the functi...

Using the dms2degree Command Sequentially to Populate an Array using a Sub-routine

With a for-loop, you need to use A in all of your indexing and use the [ ] brackets to form a vector input (and spell the functi...

ungefär 2 månader ago | 0